Repository navigation
NullPointerException can be thrown when using uber jars due to a race condition in NestedJarFileResources - #51744
Merged
philwebb merged 2 commits intoSep 15, 2026
Conversation
icikle
marked this pull request as ready for review
September 14, 2026 21:45
Update `NestedJarFileResources` to fix a race condition that could result in a `NullPointerException`. The methods `getOrCreateInflater` and `endOrCacheInflater` both synchronize on a local `inflaterCache` variable but attempted to use the `this.inflaterCache` instance which could be set to null. The `releaseInflators` method had a synchronized block for ending each inflater but the cache was being nulled out outside the block meaning that the other 2 methods mentioned could hit the race condition. Signed-off-by: Ian Kettle <[email protected]> See spring-projectsgh-51744
philwebb
force-pushed
the
concurrency-fix-to-nestedjarfileresources
branch
from
September 15, 2026 01:08
dd0f30a to
d6aac54
Compare
Member
|
Thanks very much, I've merged the fix but decided not to merge the test right now since it's quite a lot of code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related issues found while running a concurrency test targeting fixing gh-51463.
The methods getOrCreateInflater and endOrCacheInflater both synchronize on a local inflaterCache variable but attempted to use the inflaterCache instance which could be set to null.
The releaseInflators method had a synchronized block for ending each inflater but the cache was being nulled out outside the block meaning that the other 2 methods mentioned could hit a race condition resulting in a null pointer.
This change moves the nulling of the inflaterCache into the synchronized block.
See test NestedJarFileConcurrencyTests. This was written for the gh-51463 investigation and turned up this additional issue. With the previous version of the code running this test can fail due to a race condition. The failure observed in approximately 1/3 of runs was:
With the fix in place this test has not been observed to fail.