Skip to content

Commit 62936e5

Browse files
3paccccccpriyanshu-ctds
authored andcommitted
[improve][client]Add null check for Pulsar client clock configuration (apache#24848)
(cherry picked from commit 54db7f2) (cherry picked from commit 79784c0)
1 parent 46c7327 commit 62936e5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ public void testSlashSubscriptionName() throws Exception {
306306
});
307307
}
308308

309+
@Test(timeOut = 5000)
310+
public void pulsarClientClockCheckTest() {
311+
assertThatThrownBy(
312+
() -> PulsarClient.builder()
313+
.serviceUrl(lookupUrl.toString())
314+
.clock(null)
315+
.build()
316+
).isInstanceOf(IllegalArgumentException.class)
317+
.hasMessage("clock must not be null");
318+
}
319+
309320
@Test(timeOut = 100000)
310321
public void testPublishTimestampBatchEnabled() throws Exception {
311322

pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ public ClientBuilder memoryLimit(long memoryLimit, SizeUnit unit) {
365365

366366
@Override
367367
public ClientBuilder clock(Clock clock) {
368+
checkArgument(clock != null, "clock must not be null");
368369
conf.setClock(clock);
369370
return this;
370371
}

0 commit comments

Comments
 (0)