Skip to content

fix: prevent NPE when HTTP response fails in KsqlTarget#10988

Merged
Parag Badani (pbadani) merged 1 commit into7.4.xfrom
fix/ksql-target-null-response-npe
Mar 25, 2026
Merged

fix: prevent NPE when HTTP response fails in KsqlTarget#10988
Parag Badani (pbadani) merged 1 commit into7.4.xfrom
fix/ksql-target-null-response-npe

Conversation

@pbadani
Copy link
Copy Markdown
Member

Summary

  • Fixed NullPointerException in KsqlTarget.execute() when the Vert.x HTTP response handler fires with a failed async result
  • response.result() returns null on failure, but code was falling through to responseHandler.accept(response.result(), vcf), causing NPE at KsqlTarget.java:360 (resp.statusCode())
  • Added return after vcf.completeExceptionally(response.cause()) to exit the handler early on failure

Root Cause

httpClientRequest.response(response -> {
    if (response.failed()) {
        vcf.completeExceptionally(response.cause());
        // missing return — fell through to responseHandler.accept(null, vcf)
    }
    responseHandler.accept(response.result(), vcf); // NPE: response.result() is null
});

Test plan

  • Existing unit tests pass
  • Manually verify that connection failures produce a proper KsqlRestClientException instead of an NPE

🤖 Generated with Claude Code

@pbadani Parag Badani (pbadani) requested a review from a team as a code owner March 19, 2026 04:17
Copilot AI review requested due to automatic review settings March 19, 2026 04:17
@confluent-cla-assistant
Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link
Copy Markdown

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 hardens the Vert.x HTTP response handling in KsqlTarget.execute() to avoid a NullPointerException when the response callback is invoked with a failed AsyncResult.

Changes:

  • Add an early return after completeExceptionally(...) when response.failed() is true, preventing fall-through to responseHandler.accept(response.result(), ...).

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 520 to 526
httpClientRequest.response(response -> {
if (response.failed()) {
vcf.completeExceptionally(response.cause());
return;
}

responseHandler.accept(response.result(), vcf);
@airlock-confluentinc airlock-confluentinc bot force-pushed the fix/ksql-target-null-response-npe branch from e067f42 to c78cc4c Compare March 24, 2026 09:36
@pbadani Parag Badani (pbadani) changed the base branch from master to 7.4.x March 24, 2026 09:36
@airlock-confluentinc airlock-confluentinc bot force-pushed the fix/ksql-target-null-response-npe branch from c78cc4c to c4f40bd Compare March 24, 2026 12:44
@pbadani Parag Badani (pbadani) enabled auto-merge (squash) March 25, 2026 10:45
@pbadani Parag Badani (pbadani) merged commit 92ddb59 into 7.4.x Mar 25, 2026
5 checks passed
@pbadani Parag Badani (pbadani) deleted the fix/ksql-target-null-response-npe branch March 25, 2026 10:45
Parag Badani (pbadani) added a commit that referenced this pull request Mar 25, 2026
)

Co-authored-by: Parag Badani <pbadani@users.noreply.github.com>
Co-authored-by: semaphore-agent-production[bot] <117926516+semaphore-agent-production[bot]@users.noreply.github.com>
Co-authored-by: Parag Badani <pbadani@confluent.io>
Parag Badani (pbadani) added a commit that referenced this pull request Mar 26, 2026
* fix: prevent NPE when HTTP response fails in KsqlTarget (#10988)

* Fix compilation error in the unit test. (#10990)

---------

Co-authored-by: Parag Badani <pbadani@users.noreply.github.com>
Co-authored-by: semaphore-agent-production[bot] <117926516+semaphore-agent-production[bot]@users.noreply.github.com>
Co-authored-by: Parag Badani <pbadani@confluent.io>
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.

3 participants