Skip to content

Commit

Permalink
Fixes issue #24849 make relevant methods synchronized in
Browse files Browse the repository at this point in the history
LocalTxConnectionEventListener and protect associatedHandles from
external clear calls. Process review comment: use getOrDefault.
  • Loading branch information
escay committed Mar 12, 2024
1 parent db6268a commit 71d422e
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public LocalTxConnectionEventListener(ResourceHandle resource) {
@Override
public synchronized void connectionClosed(ConnectionEvent evt) {
Object connectionHandle = evt.getConnectionHandle();
ResourceHandle handle = resource;
if (associatedHandles.containsKey(connectionHandle)) {
handle = associatedHandles.get(connectionHandle);
}
ResourceHandle handle = associatedHandles.getOrDefault(connectionHandle, resource);
// ManagedConnection instance is still valid and put back in the pool: do not remove the event listener.
poolManager.resourceClosed(handle);
}
Expand All @@ -88,10 +85,7 @@ public synchronized void connectionErrorOccurred(ConnectionEvent evt) {
@Override
public synchronized void badConnectionClosed(ConnectionEvent evt) {
Object connectionHandle = evt.getConnectionHandle();
ResourceHandle handle = resource;
if (associatedHandles.containsKey(connectionHandle)) {
handle = associatedHandles.get(connectionHandle);
}
ResourceHandle handle = associatedHandles.getOrDefault(connectionHandle, resource);

// TODO: Explain why event listener needs to be removed.
// There is no documentation mentioning: ManagedConnection instance is now invalid and unusable.
Expand Down

0 comments on commit 71d422e

Please sign in to comment.