Resource not closed warning with rest client
See original GitHub issueThis is a bit hard to reproduce for me. Like in #10804 I am doing remote calls via the MP Rest Client
@Inject
@RestClient
RbacServer rbac;
...
try {
result = getRbacInfo(user.getRawRhIdHeader());
} catch (Throwable e) {
...
@CacheResult(cacheName = "rbac-cache")
RbacRaw getRbacInfo(String xrhidHeader) {
RbacRaw result;
result = rbac.getRbacInfo("policies", xrhidHeader); // <---
return result;
}
And I get (not always) the following in the logs:
2020-07-17 16:58:30,999 WARN [org.jbo.res.cli.jax.i18n] (Finalizer) RESTEASY004687: Closing a class org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine instance for you. Please close clients yourself.
Locally I could reproduce it now with the remote service returning a 401, but I also see that on our production instance, where I do not see any errors from the remote call.
2020-07-17 17:38:59,103 WARNING [RbacFilter] (executor-thread-1) Call to RBAC took 1301ms
2020-07-17 17:38:59,102 WARNING [com.git.ben.caf.cac.LocalAsyncCache] (Thread-13) Exception thrown during asynchronous load: java.util.concurrent.CompletionException: javax.ws.rs.WebApplicationException: Unknown error, status code 401
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.ws.rs.WebApplicationException: Unknown error, status code 401
at org.jboss.resteasy.microprofile.client.DefaultResponseExceptionMapper.toThrowable(DefaultResponseExceptionMapper.java:16)
at org.jboss.resteasy.microprofile.client.ExceptionMapping$HandlerException.mapException(ExceptionMapping.java:38)
at org.jboss.resteasy.microprofile.client.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:151)
at com.sun.proxy.$Proxy75.getRbacInfo(Unknown Source)
at com.redhat.cloud.policies.app.auth.RbacFilter.getRbacInfo(RbacFilter.java:95)
at com.redhat.cloud.policies.app.auth.RbacFilter_Subclass.getRbacInfo$$superaccessor1(RbacFilter_Subclass.zig:205)
at com.redhat.cloud.policies.app.auth.RbacFilter_Subclass$$function$$1.apply(RbacFilter_Subclass$$function$$1.zig:33)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.cache.runtime.CacheResultInterceptor.lambda$intercept$0(CacheResultInterceptor.java:27)
at io.quarkus.cache.runtime.caffeine.CaffeineCache$MappingSupplier.get(CaffeineCache.java:136)
at io.quarkus.cache.runtime.caffeine.CaffeineCache.lambda$get$0(CaffeineCache.java:58)
at com.github.benmanes.caffeine.cache.LocalAsyncCache.lambda$get$0(LocalAsyncCache.java:77)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
... 1 more
{"date":"Fri, 17 Jul 2020 15:38:57 GMT","method":"GET","uri":"/api/policies/v1.0/policies/123","acct":"901578","http_version":"HTTP/1.1","status":403,"content_length":0,"duration":1318,"user_agent":"curl/7.54.0","remote":"0:0:0:0:0:0:0:1"}
2020-07-17 17:39:09,854 WARN [org.jbo.res.cli.jax.i18n] (Finalizer) RESTEASY004687: Closing a class org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine instance for you. Please close clients yourself.
Commenting out the @CacheResult() makes the warning/stack trace go away, but still shows the Finalizer-warning.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Resource leak: 'in' is never closed - java - Stack Overflow
Making the scanner static means it remains open forever (or until the class get's unloaded, which nearly is "forever"). The compiler gives you...
Read more >Best Practices for REST API Error Handling - Baeldung
Learn about some of the best practices for handling REST API errors, including useful approaches for providing users with additional ...
Read more >Twitter API Response Codes & Error Support
Error responses are served with a non-200-series HTTP code. Different error codes indicate different reasons for an error. The Twitter API attempts to ......
Read more >Zalando RESTful API and Event Guidelines
7. REST Basics - URLs. SHOULD not use /api as base path; MUST pluralize resource names; MUST use URL-friendly resource identifiers; MUST use...
Read more >Use the Legacy REST API | Trend Micro Deep Security
HTTP status codes · The caller accessed an invalid URL that is not part of the REST API. · The caller specified a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am still getting the same error 2.7.5 Final. It happens almost everytime an internal REST call happens (i.e. with the Keycloak API), or an explicit one when Testing with RESTAssured.
WARN [org.jbo.res.cli.jax.i18n] (Finalizer) RESTEASY004687: Closing a class org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine instance for you. Please close clients yourself.After running all my tests, the whole console is full of those messages. They usually appear after a timeout of a couple of seconds.
Still happening at Quarkus 2.4.0-Final