Adven27 / grpc-wiremock

gRPC Mock Server
MIT License
93 stars 40 forks source link

Fix java.io.IOException: Too many open files #15

Closed DOSroblox closed 3 years ago

DOSroblox commented 3 years ago

I was running into this error frequently:

java.lang.InternalError: java.io.IOException: Too many open files
    at java.net.http/jdk.internal.net.http.HttpClientImpl.<init>(HttpClientImpl.java:311)
    at java.net.http/jdk.internal.net.http.HttpClientImpl.create(HttpClientImpl.java:253)
    at java.net.http/jdk.internal.net.http.HttpClientBuilderImpl.build(HttpClientBuilderImpl.java:135)
    at java.net.http/java.net.http.HttpClient.newHttpClient(HttpClient.java:158)
    at io.adven.grpc.wiremock.HttpMock.request(HttpMock.java:64)
    at io.adven.grpc.wiremock.HttpMock.send(HttpMock.java:59)
    at ...

this PR is one way to fix it & is what fixed the problem for me -- switching to using a single HttpClient instance rather than creating a new one for each request.