Reputation: 39
One of the endpoints in my application calls 3 REST APIs and uses webclient to do so. Everything works fine (getting the response fine from all the 3 endpoints) until I stop the application on my local workspace. I am getting below error when i try to stop the application.
o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [reactor-http-nio-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:883)
io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:526)
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
java.lang.Thread.run(Thread.java:750)
There are a total of 4 occurrences of the above error which I assume is somehow connected to the REST class I am making using webclient.
This is how one of the endpoint calls looks like:
public Void makeRestCall(Request request) {
URI endpoint = UriComponentsBuilder.fromUriString("url").build().encode().toUri();
return webClient.post().uri(endpoint).contentType(MediaType.APPLICATION_JSON)
.bodyValue(request)
.retrieve()
.onStatus(HttpStatus::is4xxClientError,
stringResponse -> stringResponse.bodyToMono(Fault.class).flatMap(
pojoResponse -> stringResponse.createException().flatMap(ex -> Mono.error(
new HttpClientErrorException(ex.getStatusCode(), "Field: " + pojoResponse.getErrors().get(0)
.getSourceProperty() + " - Error: " + pojoResponse.getErrors().get(0).getMessageID() )))))
.onStatus(HttpStatus::is5xxServerError,
stringResponse -> stringResponse.bodyToMono(Fault.class).flatMap(
pojoResponse -> stringResponse.createException().flatMap(ex -> Mono.error(
new HttpClientErrorException(ex.getStatusCode(), pojoResponse.getMessage())))))
.toBodilessEntity().block().getBody();
}
I am not sure what could be causing it, is there a way to close the webclient. I assume spring container should be doing it for us. Can someone help?
Upvotes: 0
Views: 139