Skip to content

ConcurrentModificationException during mvn test #784

@i3wangyi

Description

@i3wangyi

@narendly reported the stack trace of a problematic exception

22723 [ZkClient-EventThread-752-localhost:2183] ERROR org.apache.helix.manager.zk.ZKExceptionHandler - exception in handling data-change. path: /TestHelixAdminCli_grand/INSTANCES/controller_9000/CURRENTSTATES/10014b003960037/TestHelixAdminCli, listener: org.apache.helix.controller.GenericHelixController@64b7b07
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1442)
at java.util.HashMap$KeyIterator.next(HashMap.java:1466)
at org.apache.helix.controller.stages.ClusterEvent.clone(ClusterEvent.java:119)
at org.apache.helix.controller.GenericHelixController.pushToEventQueues(GenericHelixController.java:1010)
at org.apache.helix.controller.GenericHelixController.onStateChange(GenericHelixController.java:826)
at org.apache.helix.manager.zk.CallbackHandler.invoke(CallbackHandler.java:418)
at org.apache.helix.manager.zk.CallbackHandler.enqueueTask(CallbackHandler.java:341)
at org.apache.helix.manager.zk.CallbackHandler.handleDataChange(CallbackHandler.java:625)
at org.apache.helix.zookeeper.zkclient.ZkClient$6.run(ZkClient.java:1305)
at org.apache.helix.zookeeper.zkclient.ZkEventThread.run(ZkEventThread.java:90)
true: wait 426ms, ClusterStateVerifier$BestPossAndExtViewZkVerifier(TestHelixAdminCli@localhost:2183)
true: wait 250ms, ClusterStateVerifier$BestPossAndExtViewZkVerifier(TestHelixAdminCli@localhost:2183)
END testDropAddResource at Thu Feb 13 14:50:12 PST 2020, took: 3075ms.
START testInstanceOperations at Thu Feb 13 14:50:12 PST 2020

The root cause is: In ClusterEvent.java, the hashmap is updated in another thread while clone is still in the for-loop

for (String attributeName : _eventAttributeMap.keySet()) {
  newEvent.addAttribute(attributeName, _eventAttributeMap.get(attributeName));
}


public void addAttribute(String attrName, Object attrValue) {
  if (logger.isTraceEnabled()) {
    logger.trace("Adding attribute:" + attrName);
    logger.trace(" attribute value:" + attrValue);
  }

  _eventAttributeMap.put(attrName, attrValue);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions