Skip to content

[CELEBORN-2356] Fix NPE before null-check in handleChunkFetchRequest#3731

Open
afterincomparableyum wants to merge 1 commit into
apache:mainfrom
afterincomparableyum:CELEBORN-2356
Open

[CELEBORN-2356] Fix NPE before null-check in handleChunkFetchRequest#3731
afterincomparableyum wants to merge 1 commit into
apache:mainfrom
afterincomparableyum:CELEBORN-2356

Conversation

@afterincomparableyum

@afterincomparableyum afterincomparableyum commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

getStreamState returns null for an unknown id. The streamState.buffers pattern match dereferences it before the null guard runs, throwing NullPointerException. The intended ChunkFetchFailure reply is unreachable. Here we should reorder null-check first, then compute storageMetrics.

Why are the changes needed?

To prevent potential NPEs.

Does this PR resolve a correctness bug?

  • Yes

Does this PR introduce any user-facing change?

  • Yes

How was this patch tested?

CI/CD Unit tests.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a correctness bug in the worker fetch path where an unknown stream ID could trigger a NullPointerException before the intended ChunkFetchFailure response is sent.

Changes:

  • Reorders the streamState == null guard in FetchHandler.handleChunkFetchRequest to run before dereferencing streamState.buffers.
  • Adds a unit test that exercises chunk fetch for an unregistered stream and asserts a ChunkFetchFailure response.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/FetchHandler.scala Moves the null-check ahead of buffer-type matching to avoid NPE and return ChunkFetchFailure correctly.
worker/src/test/java/org/apache/celeborn/service/deploy/worker/FetchHandlerSuiteJ.java Adds coverage for the “unregistered stream chunk fetch” failure path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SteNicholas

Copy link
Copy Markdown
Member

@afterincomparableyum, please take a look at above comments?

@afterincomparableyum

Copy link
Copy Markdown
Contributor Author

I've addressed comments @SteNicholas

getStreamState returns null for an unknown id. The streamState.buffers pattern match dereferences it before the null guard runs, throwing NullPointerException. The intended ChunkFetchFailure reply is unreachable. Here we should reorder null-check first, then compute storageMetrics.
@afterincomparableyum

Copy link
Copy Markdown
Contributor Author

Addressed comments @SteNicholas

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants