IcePush - NegativeArraySizeException

We’ve been experiencing some strange random behavior from this add-on.

At some point it starts doing this:

Mar 18, 2013 6:13:07 PM org.icepush.servlet.EnvironmentAdaptingServlet
INFO: Adapting to Servlet 3.0 AsyncContext environment
Mar 18, 2013 6:13:07 PM org.icepush.servlet.AsyncAdaptingServlet
INFO: Using Servlet 3.0 AsyncContext
<Mar 18, 2013 6:13:08 PM CST> <[ServletContext@11051840[app:Stcv6Pruebas module:Stcv6Pruebas.war path:null spec-version:3.0]
] Servlet failed with an Exception
java.lang.RuntimeException: java.lang.RuntimeException: wrapped Exception: java.lang.NegativeArraySizeException
at org.vaadin.artur.icepush.ICEPushServlet.service(ICEPushServlet.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
Truncated. see log file for complete stacktrace
Caused By: java.lang.RuntimeException: wrapped Exception: java.lang.NegativeArraySizeException
at org.icepush.servlet.MainServlet.service(MainServlet.java:87)
at org.vaadin.artur.icepush.ICEPushServlet.service(ICEPushServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NegativeArraySizeException
at java.util.AbstractCollection.toArray(AbstractCollection.java:119)
at java.util.ArrayList.(ArrayList.java:131)
at org.icepush.servlet.BrowserDispatcher.discardUnusedServlets(BrowserDispatcher.java:89)
at org.icepush.servlet.BrowserDispatcher.service(BrowserDispatcher.java:47)
at org.icepush.servlet.PathDispatcher.service(PathDispatcher.java:45)
Truncated. see log file for complete stacktrace

It throws that error on each new session made to the server.

Our application is running on weblogic 12 using vaadin 6.8.4 and icepush 0.2.1.

I already found another thread with a similar problem but no solution was provided.

Any help would be welcome.

Hello,

i have the same problem, but i am long-running a plain java vm, no ejb-server is involved.


Exception:

java.lang.NegativeArraySizeException
at java.util.AbstractCollection.toArray(AbstractCollection.java:119)
at java.util.ArrayList.(ArrayList.java:131)
at XXX.xxx(XXX.java:xxx)


Java code at XXX:

private static Map<String, XX> xxxx = new HashMap<String, XX>();
private static void checkXX() {
for (String xxx : new ArrayList(xxxx.keySet())) {
//…
}
}


Java Info:

java -version
java version “1.6.0_26”
Java™ SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot™ Client VM (build 20.1-b02, mixed mode, sharing)

Any idea?

Chers

While the past ICEPush problem was related to
http://jira.icesoft.org/browse/PUSH-152
, the later one looks like a bug in the JVM or its standard runtime libraries if the code is really as shown here. Even failure to synchronize should produce other problems rather than this one - the only non-JRE problem I can imagine here would be static initialization order depending on where the methods are called from (if very early in the static initialization phase), but even that doesn’t look like a likely culprit here. Then again, maybe there is something relevant elsewhere in your code.

There is nothing Vaadin related involved here as far as I can see, so maybe you’d get better answers somewhere else (with some more information about the problem).

I think it was a failure to synchronize on a HashMap.
I concurrently deleted items from the HashMap and that left the HashMap in an invalid state (restart required).