-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.ArrayIndexOutOfBoundsException when using Streams sorting #5902
Comments
HI @pminearo to verify, this is happening in JIT mode, you are not using Can you reproduce the same problem on actual OpenJDK, without any GraalVM involved? Christian |
closed due to a lack of response from the reporter. |
Wanted to note that I've seen the same behaviour (not using Graal at all, actually using Amazon Corretto ( Although I do not understand the reason for it failing exactly, I had an obvious bug in my code where I forgot to change a The code that broke was literally: private final Map<String, String> calculatedHashes = new HashMap<>(100_000);
// some code to precalculate the map with using `.parallel()`
log.error("SIZE: {}", calculatedHashes.size());
log.error("KEYS: {}", calculatedHashes.keySet().stream().sorted().toList()); // ← fails here with:
I do not understand exactly why it would break at this point to be honest. I would guess that even though functionally it would be broken due to the HashMap not being thread safe, I didn't expect that getting the key set would be in this kind of 'inconsistent' state? Anyway: I cannot reproduce anymore with a |
We are having an issue in our production environment. I have a work around to it, but figured I would submit this to the group, just in case it is an actual bug in OpenJDK.
Has anyone seen this problem?
The following code:
Is throwing the following exception:
I can not reproduce this in a test. And, because our production environment can have different types of Map objects with different types of keys; I am not sure which type of Map, or key, is being passed in the method.
With that said, I am pretty sure
streams
should not be throwingArrayIndexOutOfBoundsException
. Part of the reason forstreams
is not have to worry about this type of issue.Also, there is no concurrency issues. Usually, you get a ConcurrentModificationException when a collection is modified by 2 different threads, at least we do.
I switched the code to what’s below and it works fine.
Using the List.sort() works, but sorting via Streams didn’t. This is an odd one.
My environment:
GraalVM version 22.2.0
CE or EE: CE
JDK version: JDK17
OS and OS Version: CentOS Linux release 7.9.2009
Architecture: amd64
The text was updated successfully, but these errors were encountered: