Skip to content

Conversation

@xccui
Copy link
Member

@xccui xccui commented Nov 5, 2025

What is the purpose of the change

Add null check for pauseOrResumeSplits to avoid NPE

Brief change log

Added null check for currentReader in pauseOrResumeSplits().

Verifying this change

Please make sure both new and modified tests in this PR follow the conventions for tests defined in our code quality guide.

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@xccui xccui requested a review from Copilot November 5, 2025 17:03
@flinkbot
Copy link
Collaborator

flinkbot commented Nov 5, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a null safety check to the pauseOrResumeSplits method in HybridSourceReader to prevent potential NullPointerException when the method is called before any source reader has been initialized.

  • Adds null check before delegating to the current reader's pauseOrResumeSplits method

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

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Nov 6, 2025
public void pauseOrResumeSplits(
Collection<String> splitsToPause, Collection<String> splitsToResume) {
currentReader.pauseOrResumeSplits(splitsToPause, splitsToResume);
if (currentReader != null) {
Copy link
Contributor

@davidradl davidradl Nov 6, 2025

Choose a reason for hiding this comment

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

if it is null, should we error?
Would it fail later if we do not error here ?
Can we get an empty collection here - that we could also check for?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's normal for the currentReader to be null. I'm just not sure if this method will be invoked when it happens. So just in case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had a look at the non test code, I see

pauseOrResumeSplits(Collections.singletonList(splitId), Collections.emptyList());

as the 2 callers that end up in this code - both of whom call this with a non null. I suggest we do not need the null check as this parameter is never null. Did I miss anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Actually we had used the version without the null check for several months internally and didn't hit any issues. It implies the null check could be redundant. However, potentially more code will use this method in the future. So adding the check would be a defensive measure (I actually forgot to push this commit to my previous PR). I'm fine with both.

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

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants