Skip to content

Commit

Permalink
Add null check to workaround NPE in unit tests with Mockito/PowerMock (
Browse files Browse the repository at this point in the history
…#14006)

- Fixes #13620

(cherry picked from commit e45b4f2)
  • Loading branch information
lhotari authored and codelipenghui committed Jan 30, 2022
1 parent 1d3a40e commit 4691d3e
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ public ServerCnx(PulsarService pulsar) {
}

public ServerCnx(PulsarService pulsar, String listenerName) {
super(pulsar.getBrokerService().getKeepAliveIntervalSeconds(), TimeUnit.SECONDS);
// pulsar.getBrokerService() can sometimes be null in unit tests when using mocks
// the null check is a workaround for #13620
super(pulsar.getBrokerService() != null ? pulsar.getBrokerService().getKeepAliveIntervalSeconds() : 0,
TimeUnit.SECONDS);
this.service = pulsar.getBrokerService();
this.schemaService = pulsar.getSchemaRegistryService();
this.listenerName = listenerName;
Expand Down

0 comments on commit 4691d3e

Please sign in to comment.