Fix invalid prototype slot node issue#3616
Open
weixq709 wants to merge 1 commit into
Open
Conversation
|
joyce seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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.
Describe what this PR does / why we need it
When a singleton
ProcessorSlotis placed before a prototype (non-singleton)ProcessorSlotinDefaultProcessorSlotChain, all chains share the same singletoninstance. Each time a new chain is built,
addLastcallssetNextdirectly onthe shared singleton, overwriting its
nextpointer. This causes previously builtchains to lose their own prototype slot node — making the prototype slot invalid.
This PR introduces
PrototypeSlotWrapperand modifiesDefaultProcessorSlotChain#addLastto wrap every slot in a new
PrototypeSlotWrapperper chain. Each wrapper owns anindependent
nextpointer (inherited fromAbstractLinkedProcessorSlot), so thesingleton's
nextfield is never modified during chain construction, and each chainmaintains its own correct node linkage.
Does this pull request fix one issue?
Fixes #3007
Describe how you did it
Added
PrototypeSlotWrapper(slots/block/flow/PrototypeSlotWrapper.java):a thin wrapper extending
AbstractLinkedProcessorSlotthat delegatesentry,exit,fireEntry, andfireExitto the underlying slot, while keeping itsown chain-local
nextpointer via the inherited field.Modified
DefaultProcessorSlotChain#addLast(
slotchain/DefaultProcessorSlotChain.java):wrap the incoming slot in a
PrototypeSlotWrapperbefore appending it to thechain, so
end.setNextandend = processoralways operate on a fresh wrapperinstance rather than the slot itself.
Describe how to verify it
Two test cases added in
ProcessorSlotChainTest(slots/ProcessorSlotChainTest.java):testBeforeFix_nextOfSingletonIsShared: uses a Mockito spy to simulate the oldaddLastlogic (no wrapper) and asserts that after building two chains, bothchains' prototype slot node is the same object — confirming the bug.
testAfterFix_eachChainHasItsOwnWrapper: uses the fixedDefaultProcessorSlotChainand asserts that the two chains hold different
PrototypeSlotWrapperinstances astheir second node — confirming the fix.
Special notes for reviews
PrototypeSlotWrapperdoes not overridegetNext/setNext, so the chain-localnextfield on the wrapper is used for node linkage.fireEntryandfireExitaredelegated to the underlying slot to preserve the original propagation behavior.