Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Avoid NPE when closing an uninitialized SameAuthParamsLookupAutoClusterFailover #23911

Merged

Conversation

merlimat
Copy link
Contributor

Motivation

An exception in the PulsarClientImpl constructor will lead to close the SameAuthParamsLookupAutoClusterFailover instance which might not be initialized yet. When it happens it causes an NPE that masks the original exception.

Failed to shutdown Pulsar client @timestamp=2025-01-29T20:21:32.607Z logger-name=org.apache.pulsar.client.impl.PulsarClientImpl thread-name=main level=WARN level-value=30000 stack-trace=`java.lang.NullPointerException: Cannot invoke "org.apache.pulsar.shade.io.netty.util.concurrent.ScheduledFuture.cancel(boolean)" because "this.scheduledCheckTask" is null
        at org.apache.pulsar.client.impl.SameAuthParamsLookupAutoClusterFailover.close(SameAuthParamsLookupAutoClusterFailover.java:111)
        at org.apache.pulsar.client.impl.PulsarClientImpl.shutdown(PulsarClientImpl.java:899)
        at org.apache.pulsar.client.impl.PulsarClientImpl.<init>(PulsarClientImpl.java:265)
        at org.apache.pulsar.client.impl.PulsarClientImpl.<init>(PulsarClientImpl.java:168)
        at org.apache.pulsar.client.impl.ClientBuilderImpl.build(ClientBuilderImpl.java:71)

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

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

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

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

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@merlimat merlimat added this to the 4.1.0 milestone Jan 29, 2025
@merlimat merlimat self-assigned this Jan 29, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 29, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.19%. Comparing base (bbc6224) to head (4a6ac8e).
Report is 877 commits behind head on master.

Files with missing lines Patch % Lines
.../impl/SameAuthParamsLookupAutoClusterFailover.java 33.33% 1 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23911      +/-   ##
============================================
+ Coverage     73.57%   74.19%   +0.61%     
+ Complexity    32624    31843     -781     
============================================
  Files          1877     1853      -24     
  Lines        139502   143738    +4236     
  Branches      15299    16339    +1040     
============================================
+ Hits         102638   106640    +4002     
+ Misses        28908    28683     -225     
- Partials       7956     8415     +459     
Flag Coverage Δ
inttests 26.77% <0.00%> (+2.18%) ⬆️
systests 23.22% <0.00%> (-1.11%) ⬇️
unittests 73.69% <42.85%> (+0.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rg/apache/pulsar/client/impl/PulsarClientImpl.java 75.12% <100.00%> (+0.81%) ⬆️
.../impl/SameAuthParamsLookupAutoClusterFailover.java 67.07% <33.33%> (ø)

... and 1032 files with indirect coverage changes

@merlimat merlimat merged commit 12b0579 into apache:master Jan 30, 2025
61 of 62 checks passed
codelipenghui pushed a commit that referenced this pull request Jan 30, 2025
lhotari pushed a commit that referenced this pull request Jan 30, 2025
lhotari pushed a commit that referenced this pull request Jan 30, 2025
@merlimat merlimat deleted the npe-SameAuthParamsLookupAutoClusterFailover branch January 30, 2025 16:02
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Jan 31, 2025
…oClusterFailover (apache#23911)

(cherry picked from commit 12b0579)
(cherry picked from commit c0ee989)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Feb 3, 2025
…oClusterFailover (apache#23911)

(cherry picked from commit 12b0579)
(cherry picked from commit c0ee989)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants