-
Notifications
You must be signed in to change notification settings - Fork 49
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
fix: ConcurrentModificationException on flag config change java 9 #954
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Duration; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.concurrent.BlockingQueue; | ||
import java.util.concurrent.LinkedBlockingQueue; | ||
|
@@ -98,9 +99,9 @@ public void changedFlags() throws Exception { | |
Map<String, FeatureFlag> expectedChangedFlags = | ||
FlagParser.parseString(getFlagsFromResource(VALID_LONG),true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This call would intermittently fail in Java 9+ due to concurrent modification exceptions. |
||
expectedChangedFlags.remove("myBoolFlag"); | ||
// flags changed from initial VALID_SIMPLE flag | ||
Assert.assertEquals(expectedChangedFlags.keySet().stream().collect(Collectors.toList()), | ||
storageStateDTOS.take().getChangedFlagsKeys()); | ||
// flags changed from initial VALID_SIMPLE flag, as a set because we don't care about order | ||
Assert.assertEquals(expectedChangedFlags.keySet().stream().collect(Collectors.toSet()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assert would inconsistently fail because of ordering inconsistencies. |
||
new HashSet<>(storageStateDTOS.take().getChangedFlagsKeys())); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field presents a concurrency issue, since multiple threads can possible parse at the same time, and
computeIfAbsent
can throw an concurrent-modification-exception in Java 9+