jakartaee / jakartaee/servlet

Request Cancelled Listener

Open
#156 11 comments 1 reaction 1 assignee View on GitHub

@glassfishrobot is already working on this.

Since Jun 6, 2018.

Enhancement
Dominant language
Java
Stars
325
Forks
112
PR merge metrics
No merged PRs in 30d

Description

Unlike HTTP/1 it is possible for a HTTP/2 server to know if a connection has failed or if an individual stream has been reset before normal completion. This gives the possibility of adding listeners that can inform an application that their transport is no longer functional.

Typically this would be useful if an application has dispatched an expensive and/or long running request handling process. With HTTP/1 servers, it is not generally possible to know if the connection has been closed without actually attempting IO on it, so even if a client has long ago closed the connection, the first that the expensive/long request handler will know about it is when it completes and attempts to write the response.

With HTTP/2, the connection is always IO active (as it is multiplexed), so any connection failures will be hungrily discovered with a read IOException. There are also explicit frames available to allow a particular stream to be reset.

Thus there is now scope to provide a listener API that will be called if either a connection or request failure is detected.

Something like a new Listener that has to be explicitly set via ServletRequest#addListener on a particular request:

interface ServletRequestCancellationListener

{ void cancelled(ServletRequestCancellationEvent e); }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.