[ 
https://issues.apache.org/jira/browse/KAFKA-8011?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16779605#comment-16779605
 ] 

ASF GitHub Bot commented on KAFKA-8011:
---------------------------------------

bbejeck commented on pull request #6338: KAFKA-8011: Fix for race condition 
causing ConcurrentModificationException
URL: https://github.com/apache/kafka/pull/6338
 
 
   In the `RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated()` and 
`RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenDeleted()` a race 
condition exists where the `ConsumerRebalanceListener` in the test modifies the 
list of subscribed topics when the condition for the test success is comparing 
the same array instance against expected values.
   
   This PR should fix this race condition by using a `CopyOnWriteArrayList` 
which guarantees safe traversal of the list even when a concurrent modification 
is happening.  
   
   Using the `CopyOnWriteArrayList` should not impact performance negatively as 
the number of traversals, a result of using `ArrayList.equals()`, far outnumber 
(`TestUtils.waitForCondition()` checks for a successful result every`100ms`) 
the possible modifications as there will be at most one topic name 
added/removed during the test.
   
   For testing, I updated the `RegexSourceIntegrationTest`integration test and 
ran the suite of streams tests.
   
   
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Flaky Test RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated
> ------------------------------------------------------------------------
>
>                 Key: KAFKA-8011
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8011
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: Bill Bejeck
>            Priority: Critical
>              Labels: flaky-test, newbie
>
> The RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated
> and RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenDeleted  tests use 
> an ArrayList to assert the topics assigned to the Streams application. 
> The ConsumerRebalanceListener used in the test operates on this list as does 
> the TestUtils.waitForCondition() to verify the expected topic assignments.
> Using the same list in both places can cause a ConcurrentModficationException 
> if the rebalance listener modifies the assignment at the same time 
> TestUtils.waitForCondition() is using the list to verify the expected topics. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to