1 Reply Latest reply on Mar 20, 2006 8:39 AM by timfox

    ConcurrentModificationException in InvokerRegistry

    timfox

      I'm getting a ConcurrentModificationException in InvokerRegistry.java.

      It only occurs with log level of debug or finer.

      Looking at the code:

      
      public static void destroyClientInvoker(InvokerLocator locator)
       {
       ClientInvoker invoker = null;
      
       synchronized(clientLock)
       {
       invoker = (ClientInvoker) clientLocators.remove(locator);
       }
      
       if(invoker != null)
       {
       log.debug("destroying client for locator: " + locator + ", invoker:" + invoker + ", remaining list:" + clientLocators);
      
       invoker.disconnect();
       invoker = null;
       }
      
       }
      
      


      The exception happens on the call to log.debug.

      It's happening because although most of the code is properly synchronized, the log.debug line cause toString() to be called on the map which causes it to internally interate through it's elements without locking.

      I've fixed this locally by making sure the log.debug is executed in a synch block.