mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 07:58:03 +01:00
Include HTTP/2 stream idle timeouts in IOExceptionMapper
This commit is contained in:
@@ -21,8 +21,19 @@ public class IOExceptionMapper implements ExceptionMapper<IOException> {
|
||||
public Response toResponse(IOException e) {
|
||||
if (!(e.getCause() instanceof java.util.concurrent.TimeoutException)) {
|
||||
logger.warn("IOExceptionMapper", e);
|
||||
} else if (e.getCause().getMessage().startsWith("Idle timeout expired")) {
|
||||
return Response.status(Response.Status.REQUEST_TIMEOUT).build();
|
||||
} else {
|
||||
// Some TimeoutExceptions are because the connection is idle, but are only distinguishable using the exception
|
||||
// message
|
||||
final String message = e.getCause().getMessage();
|
||||
final boolean idleTimeout =
|
||||
message != null &&
|
||||
// org.eclipse.jetty.io.IdleTimeout
|
||||
(message.startsWith("Idle timeout expired")
|
||||
// org.eclipse.jetty.http2.HTTP2Session
|
||||
|| (message.startsWith("Idle timeout") && message.endsWith("elapsed")));
|
||||
if (idleTimeout) {
|
||||
return Response.status(Response.Status.REQUEST_TIMEOUT).build();
|
||||
}
|
||||
}
|
||||
|
||||
return Response.status(503).build();
|
||||
|
||||
Reference in New Issue
Block a user