Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
7.0.0
-
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