eclipse-ee4j / eclipse-ee4j/jersey

Hanging asynchronous requests after redeploy

Open
#3,920 0 comments 0 reactions 0 assignees View on GitHub
hk2
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

I've just found this Stack Overflow question and a related email thread:

- [What is the proper way of cleaning up asynchronous requests before servlet redeploy (Jersey, Tomcat)? (SO)](https://stackoverflow.com/q/37934558/843804)
- [What is the proper way of cleaning up asynchronous requests before servlet redeploy (Jersey, Tomcat)? (email)](http://jersey.576304.n2.nabble.com/What-is-the-proper-way-of-cleaning-up-asynchronous-requests-before-servlet-redeploy-Jersey-Tomcat-td7583818.html)

It seems to me that the bug is still alive.

If I call Jersey with plain `curl` and redeploy the webapp while it is waiting for timeout `curl` actually never returns.

I've tried to add a new thread which resumes the `AsyncResponse` before the 30 seconds timeout:

final Runnable runnable = () -> {
Uninterruptibles.sleepUninterruptibly(15, TimeUnit.SECONDS);
asyncResponse.resume("response after 15 seconds");
};
final Thread thread = new Thread(runnable);
thread.setDaemon(true);
thread.start();

It results this exception and `curl` still hangs forever:

Exception in thread "Thread-40" MultiException stack 1 of 1
java.lang.IllegalStateException: ServiceLocatorImpl(__HK2_Generated_0,0,1541677313) has been shut down
at org.jvnet.hk2.internal.ServiceLocatorImpl.checkState(ServiceLocatorImpl.java:2393)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandleImpl(ServiceLocatorImpl.java:635)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:628)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:646)
at org.jvnet.hk2.internal.FactoryCreator.getFactoryHandle(FactoryCreator.java:103)
at org.jvnet.hk2.internal.FactoryCreator.dispose(FactoryCreator.java:173)
at org.jvnet.hk2.internal.SystemDescriptor.dispose(SystemDescriptor.java:542)
at org.glassfish.jersey.inject.hk2.RequestContext.lambda$findOrCreate$0(RequestContext.java:84)
at org.glassfish.jersey.internal.inject.ForeignDescriptorImpl.dispose(ForeignDescriptorImpl.java:87)
at org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.remove(Hk2RequestScope.java:150)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.release(Hk2RequestScope.java:167)
at org.glassfish.jersey.server.ServerRuntime$AsyncResponder.resume(ServerRuntime.java:918)
at org.glassfish.jersey.server.ServerRuntime$AsyncResponder.resume(ServerRuntime.java:872)
at com.example.Tracker2.lambda$0(Tracker2.java:80)
at java.lang.Thread.run(Thread.java:748)

Jersey version: 2.27
Apache Tomcat version: 8.0.52

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.