Skip to content

Commit 480ec68

Browse files
committed
Test: close http client
1 parent c2a1e16 commit 480ec68

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

etc/travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
DIR=$(cd "$(dirname "$0")"; pwd)
44

5-
sh $DIR/maven.sh -Dlogback.configurationFile=$DIR/logback-travis.xml -q checkstyle:checkstyle -P checkstyle package
5+
sh $DIR/maven.sh checkstyle:checkstyle -P checkstyle package

tests/src/test/java/io/jooby/JoobyRunner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ public void ready(SneakyThrows.Consumer2<WebClient, Server> onReady,
109109
ServerOptions options = server.getOptions();
110110
options.setPort(Integer.parseInt(System.getenv().getOrDefault("BUILD_PORT", "9999")));
111111
server.start(app);
112-
113-
onReady.accept(new WebClient(options.getPort(), followRedirects), server);
112+
try (WebClient client = new WebClient(options.getPort(), followRedirects)) {
113+
onReady.accept(client, server);
114+
}
114115
} catch (Throwable x) {
115116
x.printStackTrace();
116117
throw SneakyThrows.propagate(x);

tests/src/test/java/io/jooby/WebClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.util.concurrent.LinkedBlockingQueue;
2424
import java.util.concurrent.TimeUnit;
2525

26-
public class WebClient {
26+
public class WebClient implements AutoCloseable {
2727

2828
private class SyncWebSocketListener extends WebSocketListener {
2929

@@ -253,4 +253,9 @@ public void patch(String path, SneakyThrows.Consumer<Response> callback) {
253253
public int getPort() {
254254
return port;
255255
}
256+
257+
public void close() {
258+
client.dispatcher().executorService().shutdown();
259+
client.connectionPool().evictAll();
260+
}
256261
}

0 commit comments

Comments
 (0)