Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit 3bcc7dc

Browse files
authored
Merge pull request #15 from DOSroblox/patch-1
Fix java.io.IOException: Too many open files
2 parents d74bd37 + 55c3493 commit 3bcc7dc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/io/adven/grpc/wiremock/HttpMock.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
public class HttpMock {
2929
private static final Logger LOG = LoggerFactory.getLogger(HttpMock.class);
3030
private final WireMockServer server;
31+
private final HttpClient httpClient;
3132

3233
public HttpMock(WiremockProperties properties) {
3334
WireMockConfiguration config = wireMockConfig()
@@ -43,6 +44,7 @@ public HttpMock(WiremockProperties properties) {
4344
config.disableRequestJournal();
4445
}
4546
server = new WireMockServer(config);
47+
httpClient = HttpClient.newHttpClient();
4648
}
4749

4850
@PostConstruct
@@ -61,7 +63,7 @@ public Message send(Object message, String path, Class<?> aClass) throws IOExcep
6163

6264
private HttpResponse<String> request(String path, Object message) throws IOException, InterruptedException {
6365
LOG.info("Grpc request {}:\n{}", path, message);
64-
final HttpResponse<String> response = HttpClient.newHttpClient().send(
66+
final HttpResponse<String> response = httpClient.send(
6567
HttpRequest.newBuilder().uri(URI.create(server.baseUrl() + "/" + path)).POST(asJson(message)).build(),
6668
HttpResponse.BodyHandlers.ofString()
6769
);
@@ -94,4 +96,4 @@ static <T extends Message> T fromJson(String json, Class<?> clazz) {
9496
}
9597
}
9698
}
97-
}
99+
}

0 commit comments

Comments
 (0)