java.util.ConcurrentModificationException

JBoss Issue Tracker | Petr Sígl | 1 year ago
  1. 0

    Configuration - standalone-ha.xml: {noformat} <cache-container name="web" default-cache="repl" module="org.wildfly.clustering.web.infinispan"> <transport lock-timeout="60000"/> <replicated-cache name="repl" mode="ASYNC"> <locking isolation="READ_COMMITTED"/> <transaction locking="OPTIMISTIC"/> <file-store/> </replicated-cache> </cache-container> {noformat} After user is logged out, we invalidate session and show login page. Problem is, that sometimes server crashed with ConcurrentModificationException. {noformat} 2015-09-10 08:55:24,571 ERROR [io.undertow.request] (default task-10) UT005023: Exception handling request to /blabla/login: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429) at java.util.HashMap$KeyIterator.next(HashMap.java:1453) at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findListeners(InfinispanSessionManager.java:400) at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.triggerPostActivationEvents(InfinispanSessionManager.java:387) at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:245) at org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:115) at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:723) at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:753) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:64) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 2015-09-10 08:55:24,574 ERROR [cz.blabla.portal.error.ErrorHelper] (default task-10) HTTP error code 500 -> redirecting to default ERROR PAGE. Cause: null: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429) at java.util.HashMap$KeyIterator.next(HashMap.java:1453) at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findListeners(InfinispanSessionManager.java:400) at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.triggerPostActivationEvents(InfinispanSessionManager.java:387) at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:245) at org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:115) at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:723) at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:753) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:64) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) {noformat} I think, that problem is in method InfinispanSessionManager.findListeners. We have fix it with not very nice try - catch, maybe better way is to copy collection of names and iterate over it... I know it is not very nice and to be honest, I don't know if it is "right", but better then error page after logout :-). {noformat} private static List<HttpSessionActivationListener> findListeners(ImmutableSession session) { List<HttpSessionActivationListener> listeners = new ArrayList<>(); try { ImmutableSessionAttributes attributes = session.getAttributes(); Set<String> names = attributes.getAttributeNames(); if (names != null && !names.isEmpty()) { for (String name: names) { Object attribute = attributes.getAttribute(name); if (attribute instanceof HttpSessionActivationListener) { listeners.add((HttpSessionActivationListener) attribute); } } } } catch (Exception e) { InfinispanWebLogger.ROOT_LOGGER.tracef("No session attributes found.", e); } return listeners; } {noformat}

    JBoss Issue Tracker | 1 year ago | Petr Sígl
    java.util.ConcurrentModificationException
  2. 0

    Concurrency issues when preparing IR for interpretation

    GitHub | 2 years ago | headius
    java.util.ConcurrentModificationException
  3. 0

    Failed to handle packet

    GitHub | 2 years ago | mjl1010
    java.util.ConcurrentModificationException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Random server crashes

    GitHub | 2 years ago | oleg599
    java.util.ConcurrentModificationException
  6. 0

    Robots getting killed by growing trees (probably)

    GitHub | 2 years ago | Namarius
    java.util.ConcurrentModificationException
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.util.ConcurrentModificationException

    No message provided

    at java.util.HashMap$HashIterator.nextNode()
  2. Java RT
    HashMap$KeyIterator.next
    1. java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
    2. java.util.HashMap$KeyIterator.next(HashMap.java:1453)
    2 frames
  3. org.wildfly.clustering
    InfinispanSessionManager.findSession
    1. org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findListeners(InfinispanSessionManager.java:400)
    2. org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.triggerPostActivationEvents(InfinispanSessionManager.java:387)
    3. org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:245)
    3 frames
  4. WildFly: Web session clustering - Undertow integration
    DistributableSessionManager.getSession
    1. org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:115)
    1 frame
  5. Undertow Servlet
    CachedAuthenticatedSessionHandler.handleRequest
    1. io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:723)
    2. io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:753)
    3. io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:64)
    3 frames
  6. Undertow Core
    PredicateHandler.handleRequest
    1. io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    2. io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    3. io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    3 frames
  7. WildFly: Undertow
    JACCContextIdHandler.handleRequest
    1. org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    1 frame
  8. Undertow Core
    PredicateHandler.handleRequest
    1. io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    2. io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    2 frames
  9. Undertow Servlet
    ServletInitialHandler$1.handleRequest
    1. io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
    2. io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
    3. io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
    4. io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
    4 frames
  10. Undertow Core
    HttpServerExchange$1.run
    1. io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
    2. io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
    2 frames
  11. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    3. java.lang.Thread.run(Thread.java:745)
    3 frames