Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-1827

Possible java.util.ConcurrentModificationException with ValidatingGenericConnectionManager

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.0.0
    • 7.0.1
    • TomEE Core Server
    • None

    Description

      When validating Resource Adapters connections with ValidatingGenericConnectionManager, there is a case that just hands over the pool object directly to the validate method, which may cause multiple Timer threads to change the connections Set.

      For instance, the validate method might be iterating the connections set, while at the same time the FillTask Timer thread is filling the min pool. Both in the same object.

      Here is the code:

      else if (stack instanceof SinglePoolMatchAllConnectionInterceptor) {
                              connections = (Map<ManagedConnection, ManagedConnectionInfo>) pool;
                          }
      
      ...
      
      final Set<ManagedConnection> invalids = ValidatingManagedConnectionFactory.class.cast(getManagedConnectionFactory())
                                  .getInvalidConnections(connections.keySet());
      

      This can happen depending on the logic implemented by the Resource Adapter in the getInvalidConnections method.

      A workaround is to extend the Resource Adapter, override the getInvalidConnections and just place the original Set elements into a new Set and call the super method.

      Reproduced here:
      https://github.com/radcortez/tomee-resource-adapter
      mvn test -Dtest=com.radcortez.tomee.ra.SampleResourceAdapterValidationTest

      Attachments

        1. TOMEE-1827.patch
          2 kB
          Roberto Cortez

        Activity

          People

            romain.manni-bucau Romain Manni-Bucau
            radcortez Roberto Cortez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: