Skip to content

Commit 7f505c2

Browse files
committed
Updated channel validation exception messages
1 parent 47d40a6 commit 7f505c2

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/java/emissary/grpc/channel/ChannelManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@ protected String validateHostName(String host) {
9595
if (host.equals(LOCALHOST) || host.startsWith(DNS_PREFIX)) {
9696
return host;
9797
}
98-
throw new IllegalArgumentException(String.format("Expected DNS URI prefix \"dns:///\" but got \"%s\"", host));
98+
throw new IllegalArgumentException(
99+
String.format("Expected \"%s\" or DNS URI prefix \"%s\" but got \"%s\"", LOCALHOST, DNS_PREFIX, host));
99100
}
100101

101102
protected int validatePortNumber(int port) {
102103
if (port > 0 && port <= MAX_PORT_NUMBER) {
103104
return port;
104105
}
105-
throw new IllegalArgumentException(String.format("Port \"%d\" is outside valid range [1, %d]", port, MAX_PORT_NUMBER));
106+
throw new IllegalArgumentException(
107+
String.format("Port \"%d\" is outside valid range [1, %d]", port, MAX_PORT_NUMBER));
106108
}
107109

108110
protected String createTarget(String host, int port) {

src/test/java/emissary/grpc/channel/ChannelManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void testGoodHostName(String host) {
2525
void testBadHostName(String host) {
2626
Runnable invocation = () -> new TestChannelManager(host, 1).close();
2727
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, invocation::run);
28-
assertEquals(String.format("Expected DNS URI prefix \"dns:///\" but got \"%s\"", host), e.getMessage());
28+
assertEquals(String.format("Expected \"localhost\" or DNS URI prefix \"dns:///\" but got \"%s\"", host), e.getMessage());
2929
}
3030

3131
@ParameterizedTest

0 commit comments

Comments
 (0)