Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Thread safeness of LocalTxConnectionEventListener #24849

Closed
escay opened this issue Mar 10, 2024 · 0 comments · Fixed by #24851
Closed

Improve Thread safeness of LocalTxConnectionEventListener #24849

escay opened this issue Mar 10, 2024 · 0 comments · Fixed by #24851
Labels
bug Something isn't working
Milestone

Comments

@escay
Copy link
Contributor

escay commented Mar 10, 2024

Improve Thread safeness of LocalTxConnectionEventListener to prevent errors like:

Caused by: java.lang.NullPointerException: Cannot invoke "com.sun.enterprise.resource.ResourceHandle.getResourceSpec()" because "resource" is null
        at com.sun.enterprise.resource.pool.PoolManagerImpl.resourceClosed(PoolManagerImpl.java:367)
        at com.sun.enterprise.resource.listener.LocalTxConnectionEventListener.connectionClosed(LocalTxConnectionEventListener.java:58)
        at com.sun.gjc.spi.ManagedConnectionImpl.connectionClosed(ManagedConnectionImpl.java:735)
        at com.sun.gjc.spi.base.ConnectionHolder.close(ConnectionHolder.java:193)
        at com.sun.gjc.spi.jdbc40.ConnectionHolder40.close(ConnectionHolder40.java:590)

to improve the contents of the associatedHandles Map to be more threadsafe.

As part of the investigation of #24805 I ran into similar Payara issue: payara/Payara#3029 which I logged in the past. This was fixed in payara/Payara@c09e8aa

Fix idea:

  • improve calls to "private IdentityHashMap associatedHandles;" to be more thread safe, preventing poolManager.resourceClosed(handle); to be called if another thread already updated associatedHandles.
  • refactor com.sun.enterprise.resource.ConnectorXAResource.resetAssociation() logic -> so no external classes are updating associatedHandles anymore, making updating the associatedHandles the responsibility of class LocalTxConnectionEventListener
escay added a commit to escay/glassfish that referenced this issue Mar 11, 2024
LocalTxConnectionEventListener and protect associatedHandles from
external clear calls.
escay added a commit to escay/glassfish that referenced this issue Mar 11, 2024
…LocalTxConnectionEventListener and protect associatedHandles from external clear calls.

Fixes issue eclipse-ee4j#24849 make relevant methods synchronized in LocalTxConnectionEventListener and protect associatedHandles from external clear calls.
escay added a commit to escay/glassfish that referenced this issue Mar 11, 2024
LocalTxConnectionEventListener and protect associatedHandles from
external clear calls. Process review comment and fix typo.
escay added a commit to escay/glassfish that referenced this issue Mar 12, 2024
LocalTxConnectionEventListener and protect associatedHandles from
external clear calls. Process review comment: use getOrDefault.
dmatej added a commit that referenced this issue Mar 13, 2024
Fixes issue #24849 make relevant methods synchronized in LocalTxConnectionEventListener
@dmatej dmatej added this to the 7.0.14 milestone Mar 13, 2024
@dmatej dmatej added the bug Something isn't working label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants