Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public String lookup(final String key) {
}
final String[] keys = key.trim().split("\\|");
final int keyLen = keys.length;
if (keyLen == 0) {
return null;
}
final String subKey = keys[0].trim();
final String subValue = keyLen < 2 ? key : keys[1].trim();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ void testName() throws UnknownHostException {
assertTrue(matched);
}

@Test
void testDelimiterOnlyKey() {
// A key that is only delimiter/whitespace splits to an empty array; must not throw.
assertNull(DnsStringLookup.INSTANCE.apply("|"));
assertNull(DnsStringLookup.INSTANCE.apply("||"));
assertNull(DnsStringLookup.INSTANCE.apply(" | "));
}

@Test
void testNull() {
assertNull(DnsStringLookup.INSTANCE.apply(null));
Expand Down
Loading