eclipse-ee4j / eclipse-ee4j/jersey
Use of @Suspended in combination with RequestEventListener issue
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
Here is a simple example RequestEventListener to demonstrate my problem
```
import com.google.common.collect.ImmutableSet;
import java.util.Set;
import org.glassfish.jersey.server.monitoring.RequestEvent;
import org.glassfish.jersey.server.monitoring.RequestEvent.Type;
import org.glassfish.jersey.server.monitoring.RequestEventListener;
public class SampleEventListener implements RequestEventListener {
@Override
public void onEvent(RequestEvent event) {
Set requestTypes = ImmutableSet.of(Type.RESP_FILTERS_FINISHED, Type.FINISHED);
if (requestTypes.contains(event.getType())) {
System.out.println(event.getContainerRequest().getPropertiesDelegate().getPropertyNames());
}
}
}
```
If this event listener is as part of a normal request lifecycle, the properties are kept. However, if the resource is switched to using "@Suspended", the listener stops working. It looks like the problem is that close is called on the async state object which recycles the request BEFORE the finished is called, which prevents us from being able to close metrics after the response is written. Is this a known issue? It looks like it might be similar to this https://github.com/jersey/jersey/issues/3397
Contributor guide
Assessment
This issue has not been assessed yet.