Skip to content

Commit 7582ff2

Browse files
committed
Issue javaee-samples#20 Don't hide exceptions to the test, null is ugly
- throws IllegalStateException if it cannot get session in 5 seconds - (fail fast as possible)
1 parent ffc9394 commit 7582ff2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

servlet/http2/src/test/java/org/javaee8/servlet/http2/JettyConnector.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,11 @@ private Session createSession(String host, int port, boolean secure) {
167167
client.connect(new InetSocketAddress(host, port), new ServerSessionListener.Adapter(), sessionPromise);
168168
}
169169

170-
Session session = null;
171170
try {
172-
session = sessionPromise.get(5, TimeUnit.SECONDS);
171+
return sessionPromise.get(5, TimeUnit.SECONDS);
173172
} catch (InterruptedException | ExecutionException | TimeoutException e) {
174-
e.printStackTrace();
173+
throw new IllegalStateException("Cloud not get a session.", e);
175174
}
176-
return session;
177175
}
178176

179-
}
177+
}

0 commit comments

Comments
 (0)