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
  • Loading branch information
lhotari authored and nicklixinyang committed Apr 20, 2022
1 parent 27776c0 commit 7b9ac49
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,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 7b9ac49

Please sign in to comment.