Skip to content

Commit 3bc5f8b

Browse files
sonus21claude
andcommitted
fix: null-guard serverInfo in NatsProvisioner to fix unit tests
connection.getServerInfo() can return null (e.g. on a Mockito mock or before the handshake completes). Guard both the version check and the log statement so schedulingSupported defaults to false instead of NPE-ing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0f3f5fa commit 3bc5f8b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

rqueue-nats/src/main/java/com/github/sonus21/rqueue/nats/internal/NatsProvisioner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ public NatsProvisioner(Connection connection, JetStreamManagement jsm, RqueueNat
7676
this.jsm = jsm;
7777
this.config = config;
7878
io.nats.client.api.ServerInfo serverInfo = connection.getServerInfo();
79-
this.schedulingSupported = serverInfo.isSameOrNewerThanVersion(SCHEDULING_MIN_VERSION);
79+
this.schedulingSupported =
80+
serverInfo != null && serverInfo.isSameOrNewerThanVersion(SCHEDULING_MIN_VERSION);
8081
log.log(
8182
Level.INFO,
8283
"NATS server version={0}; message scheduling (ADR-51) supported={1}",
83-
new Object[] {serverInfo.getVersion(), schedulingSupported});
84+
new Object[] {serverInfo != null ? serverInfo.getVersion() : "unknown", schedulingSupported});
8485
}
8586

8687
/** Returns {@code true} when the connected NATS server supports message scheduling (>= 2.12). */

0 commit comments

Comments
 (0)