This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release18.12 by this push:
new f9d79d4ef8 Fixed: Fix some bugs SpotBugs reports (OFBIZ-12386)
f9d79d4ef8 is described below
commit f9d79d4ef8ee161aad912654376683b96d19e4d6
Author: Jacques Le Roux <[email protected]>
AuthorDate: Wed Sep 28 19:18:15 2022 +0200
Fixed: Fix some bugs SpotBugs reports (OFBIZ-12386)
Fixes the error below that returns a HTTP 500 code when "cookies" is null
Sep 28, 2022 1:57:20 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ControlServlet] in context with path
[/catalog] threw exception
java.lang.ArrayStoreException: javax.servlet.http.Cookie
at java.base/java.util.stream.Nodes$FixedNodeBuilder.accept(Nodes.java:1230)
at
java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:550)
at
java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
at
java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:517)
at
org.apache.ofbiz.webapp.stats.VisitHandler.getVisitor(VisitHandler.java:231)
It breaks OFBiz when Debug.verbose is on and in serverstats.properties these
defaults are used:
# Specify whether to use the visit history feature or not
stats.persist.visit=true
stats.persist.visitor=true
I found this error in stable demo console log after the demo was broken.
I must say I'm not very proud of what I did with
https://github.com/apache/ofbiz-framework/commit/f126bae
It was obviously wrong :)
Conflicts handled by hand in VisitHandler.java
---
.../src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
index 8b9549b24b..091d98c1f3 100644
---
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
+++
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
@@ -227,10 +227,10 @@ public class VisitHandler {
// first try to get the current ID from the
visitor cookie
String cookieVisitorId = null;
Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
if (Debug.verboseOn()) {
Debug.logVerbose("Cookies:" + String.join(",",
Arrays.stream(cookies).toArray(String[]::new)), module);
}
- if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
if
(cookies[i].getName().equals(visitorCookieName)) {
cookieVisitorId =
cookies[i].getValue();