Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove logging for duplicate termination in Jersey router #2316

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

Scottmitch
Copy link
Member

Motivation:
DefaultJerseyStreamingHttpRouter relies upon the ContainerResponseWriter to
terminate the request, and therefore the reactive stream subscriber. However
it wasn't known if there were control flows that may result in duplicate
termination so defensive code was added to guard against this case.
During shutdown it is possible for the ApplicationHandler#handle(..) method
to throw and in this case duplicate termination maybe expected. We currently
log an error because this wasn't expected but this raises false alarms and
should be removed.

java.lang.IllegalStateException: ServiceLocatorImpl(__HK2_Generated_0,0,891192830) has been shut down
	at org.jvnet.hk2.internal.ServiceLocatorImpl.checkState(ServiceLocatorImpl.java:2370)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandleImpl(ServiceLocatorImpl.java:612)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:605)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:623)
	at org.jvnet.hk2.internal.FactoryCreator.getFactoryHandle(FactoryCreator.java:79)
	at org.jvnet.hk2.internal.FactoryCreator.dispose(FactoryCreator.java:149)
	at org.jvnet.hk2.internal.SystemDescriptor.dispose(SystemDescriptor.java:518
	at org.glassfish.jersey.inject.hk2.RequestContext.lambda$findOrCreate$0(RequestContext.java:60)
	at org.glassfish.jersey.internal.inject.ForeignDescriptorImpl.dispose(ForeignDescriptorImpl.java:63)
	at org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.remove(Hk2RequestScope.java:126)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.release(Hk2RequestScope.java:143)
	at org.glassfish.jersey.process.internal.RequestScope.release(RequestScope.java:246)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:267)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
	at io.servicetalk.http.router.jersey.DefaultJerseyStreamingHttpRouter.handle0(DefaultJerseyStreamingHttpRouter.java:261)

Motivation:
DefaultJerseyStreamingHttpRouter relies upon the `ContainerResponseWriter` to
terminate the request, and therefore the reactive stream subscriber. However
it wasn't known if there were control flows that may result in duplicate
termination so defensive code was added to guard against this case.
During shutdown it is possible for the `ApplicationHandler#handle(..)` method
to throw and in this case duplicate termination maybe expected. We currently
log an error because this wasn't expected but this raises false alarms and
should be removed.

```
java.lang.IllegalStateException: ServiceLocatorImpl(__HK2_Generated_0,0,891192830) has been shut down
	at org.jvnet.hk2.internal.ServiceLocatorImpl.checkState(ServiceLocatorImpl.java:2370)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandleImpl(ServiceLocatorImpl.java:612)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:605)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getServiceHandle(ServiceLocatorImpl.java:623)
	at org.jvnet.hk2.internal.FactoryCreator.getFactoryHandle(FactoryCreator.java:79)
	at org.jvnet.hk2.internal.FactoryCreator.dispose(FactoryCreator.java:149)
	at org.jvnet.hk2.internal.SystemDescriptor.dispose(SystemDescriptor.java:518
	at org.glassfish.jersey.inject.hk2.RequestContext.lambda$findOrCreate$0(RequestContext.java:60)
	at org.glassfish.jersey.internal.inject.ForeignDescriptorImpl.dispose(ForeignDescriptorImpl.java:63)
	at org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.remove(Hk2RequestScope.java:126)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.release(Hk2RequestScope.java:143)
	at org.glassfish.jersey.process.internal.RequestScope.release(RequestScope.java:246)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:267)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
	at io.servicetalk.http.router.jersey.DefaultJerseyStreamingHttpRouter.handle0(DefaultJerseyStreamingHttpRouter.java:261)
```
@Scottmitch Scottmitch marked this pull request as ready for review August 10, 2022 14:29
@idelpivnitskiy
Copy link
Member

I will pull this in, thank you!

@idelpivnitskiy idelpivnitskiy merged commit a99f319 into apple:main Aug 10, 2022
@Scottmitch Scottmitch deleted the jersey_log branch August 11, 2022 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants