Skip to content

Commit fceb60d

Browse files
committed
fix(config): accept '_' digit separator in addr port
parsePort used Integer.parseInt, which rejects underscores, while every other numeric config key parses via Numbers.parseInt/parseLong, which treat '_' as a digit-group separator. The merge-base ingress parser (Sender.addAddressEntry) also used Numbers.parseInt, so addr=host:9_000 parsed before this refactor and regressed to rejection. Switch parsePort to Numbers.parseInt (catching NumericException) to restore prior behaviour and align addr with the other numeric keys.
1 parent 98269c8 commit fceb60d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

core/src/main/java/io/questdb/client/impl/ConfigView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ private static boolean outOfRange(ConfigSchema.KeySpec spec, long v) {
234234
private static int parsePort(String portStr, String entry) {
235235
int port;
236236
try {
237-
port = Integer.parseInt(portStr.trim());
238-
} catch (NumberFormatException e) {
237+
port = Numbers.parseInt(portStr.trim());
238+
} catch (NumericException e) {
239239
throw new IllegalArgumentException("invalid port in addr: " + entry);
240240
}
241241
if (port < 1 || port > 65535) {

core/src/test/java/io/questdb/client/test/impl/ConfigViewTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ public void testAddrEmptyEntryRejected() {
6161
assertParseError("ws::addr=a,,b;", "empty addr entry");
6262
}
6363

64+
@Test
65+
public void testAddrPortAcceptsUnderscoreSeparator() {
66+
// Numeric config keys parse with Numbers.parseInt, which treats '_' as
67+
// a digit-group separator; the addr port must stay consistent.
68+
Assert.assertEquals(list("h:9000"), hostPorts("ws::addr=h:9_000;"));
69+
Assert.assertEquals(list("::1:9001"), hostPorts("ws::addr=[::1]:9_001;"));
70+
}
71+
6472
@Test
6573
public void testAddrPortOutOfRangeRejected() {
6674
assertParseError("ws::addr=h:0;", "port out of range in addr");

0 commit comments

Comments
 (0)