Skip to content
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

SubsMapHelper has the possibility of ConcurrentModificationException #151

Open
bigtrouble opened this issue Jul 5, 2024 · 1 comment
Open
Labels

Comments

@bigtrouble
Copy link

Questions

Found the following error message on my system.

java.util.ConcurrentModificationException: null
        at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:1023)
        at java.base/java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:1046)
        at io.vertx.spi.cluster.zookeeper.impl.SubsMapHelper.lambda$childEvent$14(SubsMapHelper.java:187)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:261)
        at io.vertx.core.impl.ContextInternal.lambda$runOnContext$0(ContextInternal.java:59)
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Version

4.5.8

Extra

Collections.synchronizedSet is not synchronized in a useful way.
Using CopyOnWriteArraySet might be a good way.

io.vertx.spi.cluster.zookeeper.impl.SubsMapHelper (line: 86)

  private Set<RegistrationInfo> addToSet(RegistrationInfo registrationInfo, Set<RegistrationInfo> curr) {
    Set<RegistrationInfo> res = curr != null ? curr : Collections.synchronizedSet(new LinkedHashSet<>());
    res.add(registrationInfo);
    return res;
  }

io.vertx.spi.cluster.zookeeper.impl.SubsMapHelper (line: 186)

   for (Map.Entry<String, Set<RegistrationInfo>> entry : ownSubs.entrySet()) {
      for (RegistrationInfo registrationInfo : entry.getValue()) {
         Promise<Void> promise = Promise.promise();
         put(entry.getKey(), registrationInfo, promise);
         futures.add(promise.future());
      }
   }
@bigtrouble bigtrouble added the bug label Jul 5, 2024
@tsegismont
Copy link
Contributor

Would you like to share a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants