Skip to content

Comments

Add null guard for weak reference entries in preRollback()#532

Open
jasper-vandemalle wants to merge 2 commits intodatanucleus:masterfrom
jasper-vandemalle:nullguard
Open

Add null guard for weak reference entries in preRollback()#532
jasper-vandemalle wants to merge 2 commits intodatanucleus:masterfrom
jasper-vandemalle:nullguard

Conversation

@jasper-vandemalle
Copy link

Adds a null check in the preRollback() iteration over enlistedSMCache values.

enlistedSMCache is a ConcurrentReferenceHashMap with ReferenceType.WEAK values, so the GC can clear entries at any time. During preRollback() iteration, a cleared weak reference causes the iterator to return null, and the subsequent sm.preRollback() call throws NPE.

Fix: null guard with continue. No error logging, because this is an expected race condition with weak references, not an error.

Fixes #531

Test: ExecutionContextNullSMGuardTest injects a null entry into the cache via reflection and verifies preRollback() completes without NPE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in preRollback() when GC clears weak references in enlistedSMCache

1 participant