Description
Seen in a PR pre-checkin test run:
org.apache.geode.redis.session.SessionsAndCrashesDUnitTest > sessionOperationsDoNotFail_whileServersAreRestarted FAILED java.lang.IndexOutOfBoundsException: Index -5 out of bounds for length 100 at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) at java.util.Objects.checkIndex(Objects.java:372) at java.util.ArrayList.get(ArrayList.java:459) at org.apache.geode.redis.session.SessionsAndCrashesDUnitTest.validateSessionAttributes(SessionsAndCrashesDUnitTest.java:179) at org.apache.geode.redis.session.SessionsAndCrashesDUnitTest.sessionOperationsDoNotFail_whileServersAreRestarted(SessionsAndCrashesDUnitTest.java:170)
This occurs in the below block when totalUpdates is less than NUM_SESSIONS.
for (int i = totalUpdates - NUM_SESSIONS; i < totalUpdates; i++) { int sessionIdx = i % NUM_SESSIONS; String sessionId = sessionIds.get(sessionIdx); ...
Running the test locally with some trace logging added, it seems that totalUpdates is typically ~120, so if something were to cause updates to be 20% slower on a run of the test, this failure could show up. A solution might be to either await until at least NUM_SESSIONS updates have been performed by the updater threads, or to put in some logic to handle the case when totalUpdates is less than NUM_SESSIONS.