SLING-13236 - MapEntries: NPE when resource change is delivered during construction or disposal#210
Open
ciechanowiec wants to merge 4 commits into
Open
SLING-13236 - MapEntries: NPE when resource change is delivered during construction or disposal#210ciechanowiec wants to merge 4 commits into
ciechanowiec wants to merge 4 commits into
Conversation
…g construction or disposal
The MapEntries constructor registered itself as a ResourceChangeListener
before assigning the VanityPathHandler field, so a change delivered by the
asynchronous "Apache Sling Resource Provider Change Notifier" thread in
that window caused:
java.lang.NullPointerException: Cannot invoke
"...VanityPathHandler.isReady()" because "this.vph" is null
at ...MapEntries.onChange(MapEntries.java:460)
Symmetrically, dispose() tore down the AliasHandler before unregistering
the listener, allowing the equivalent NPE on "this.ah" during shutdown.
Fix: assign the VanityPathHandler before registering the listener (events
arriving before initializeVanityPaths completes are queued and drained by
the initializer, as designed), and unregister the listener first in
dispose(). Add deterministic regression tests for both races.
joerghoh
approved these changes
Jun 6, 2026
joerghoh
left a comment
Contributor
There was a problem hiding this comment.
lgtm
you might consider the apply the 2 nitpicks; the sling resourceresolver is entirely resource-based and does not know about "nodes" at all.
…apEntriesTest.java Co-authored-by: Jörg Hoh <joerghoh@users.noreply.github.com>
…apEntriesTest.java Co-authored-by: Jörg Hoh <joerghoh@users.noreply.github.com>
|
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.



Fixes SLING-13236.