Skip to content

Commit 63c008b

Browse files
3paccccccmanas-ctds
authored andcommitted
[improve][client]Add null check for Pulsar client clock configuration (apache#24848)
(cherry picked from commit 54db7f2) (cherry picked from commit fb1b2a5)
1 parent 1206d9f commit 63c008b

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
@@ -319,6 +319,17 @@ public void testSlashSubscriptionName() throws Exception {
319319
});
320320
}
321321

322+
@Test(timeOut = 5000)
323+
public void pulsarClientClockCheckTest() {
324+
assertThatThrownBy(
325+
() -> PulsarClient.builder()
326+
.serviceUrl(lookupUrl.toString())
327+
.clock(null)
328+
.build()
329+
).isInstanceOf(IllegalArgumentException.class)
330+
.hasMessage("clock must not be null");
331+
}
332+
322333
@Test(timeOut = 100000)
323334
public void testPublishTimestampBatchEnabled() throws Exception {
324335

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
@@ -380,6 +380,7 @@ public ClientBuilder memoryLimit(long memoryLimit, SizeUnit unit) {
380380

381381
@Override
382382
public ClientBuilder clock(Clock clock) {
383+
checkArgument(clock != null, "clock must not be null");
383384
conf.setClock(clock);
384385
return this;
385386
}

0 commit comments

Comments
 (0)