Fix for data structure concurrentHashmap which results in flaky-tests #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview:
Change
concurrentHashMap
toCollections.synchronizedMap(new HashMap<>())
as it results in flaky tests for the testcom.cerner.common.kafka.consumer.ProcessingKafkaConsumerTest.nextRecord_fairProcessing
Command to reproduce:
mvn -pl common-kafka edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=com.cerner.common.kafka.consumer.ProcessingKafkaConsumerTest#nextRecord_fairProcessing
Result:
The test fails on 4/5 iterations of the Nondex tool
Reason:
According to concurrentHashMap documentation,
"Because the elements of a ConcurrentHashMap are not ordered in any particular way, and may be processed in different orders in different parallel executions, the correctness of supplied functions should not depend on any ordering"
About the tool used to detect the Error:
This test is detected as flaky by the NonDex tool developed by researchers at UIUC.
Flaky tests are tests in software development that produce inconsistent or unreliable results, which can lead to false non-deterministic outcomes of the test case, fixing them is important to both reliable testing and fixing vulnerabilities in the code.