Details
Description
When using Xstream 1.4.4 on AIX 7.1 using the IBM 32-bit SDK for AIX, Version 6 we get the following exception:
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -1
at com.thoughtworks.xstream.core.util.OrderRetainingMap.entrySet(OrderRetainingMap.java:77)
at java.util.HashMap.putAllImpl(HashMap.java:678)
at java.util.HashMap.putAll(HashMap.java:669)
at com.thoughtworks.xstream.core.util.OrderRetainingMap.<init>(OrderRetainingMap.java:36)
This doesn't happen on previous versions of Xstream.
The problem seems to stem from a change in OrderRetainingMap.
One of the constructors changed, and the change reflects a specific internal behavior in HashMap implementation that is not consistent across JRE implementations.
OrderRetainingMap calls putAll and assumes that putAll will call put.
Issue Links
- is duplicated by
-
XSTR-746 ArrayIndexOutOfBoundsException in OrderRetainingMap when serialiazing nested class in Oracle JDK8-ea-b108
Actually the assumption is correct, but it fails before it can call put on each element. See, the stack trace implies that we are dealing here with two instances of OrderRetainingMap. One is provided as argument for the new one. The AIOOBE is actually risen in the entrySet() method for the provided instance. Since this method has also be called in the old implementation, I doubt that the call of putAll does actually make a difference. For me this looks more like a concurrency problem, because a key in the provided map has suddenly vanished.
Can you provide a complete stack trace?