Skip to content

Fix NPE in canCompleteSwap when path doesn't exist - #3162

Open
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:master
Open

Fix NPE in canCompleteSwap when path doesn't exist#3162
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:master

Conversation

@waterWang

Copy link
Copy Markdown

Description

When baseAccessor.getChildNames() returns null because the current state path for the swap-out instance doesn't exist, iterating over the result causes a NullPointerException.

Fix

Added a null check that returns true when no current states are found, indicating the swap is complete (there are no current states to transfer).

Root Cause

BaseDataAccessor.getChildNames() returns null when the ZNode path doesn't exist. The code at line 555 iterates over the result without a null check, causing NPE.

Fixes #3069

Testing

  • Existing tests should continue to pass
  • When the path doesn't exist, the method now safely returns true instead of throwing NPE

When baseAccessor.getChildNames() returns null because the current state
path doesn't exist, iterating over the result causes a NullPointerException.
Added a null check that returns true when no current states are found,
indicating the swap is complete.

Fixes apache#3069
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 canCompleteSwap if path doesn't exists

1 participant