Skip to content

Commit 32963a6

Browse files
committed
Improve asyncContext timeout handling
1 parent 884e34a commit 32963a6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

jetty/src/main/scala/com/avsystem/commons/jetty/rpc/JettyRPCFramework.scala

+8-6
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,17 @@ object JettyRPCFramework extends StandardRPCFramework with LazyLogging {
109109
code
110110
asyncContext.complete()
111111
}
112-
completeWith(Future.fromTry(call).flatMapNow(handlePost).andThenNow {
112+
Future.fromTry(call).flatMapNow(handlePost).onCompleteNow {
113113
case Success(responseContent) =>
114-
response.setContentType(MimeTypes.Type.APPLICATION_JSON.asString())
115-
response.setCharacterEncoding(StandardCharsets.UTF_8.name())
116-
response.getWriter.write(responseContent.s)
114+
completeWith {
115+
response.setContentType(MimeTypes.Type.APPLICATION_JSON.asString())
116+
response.setCharacterEncoding(StandardCharsets.UTF_8.name())
117+
response.getWriter.write(responseContent.s)
118+
}
117119
case Failure(t) =>
118-
response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500, t.getMessage)
120+
completeWith(response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500, t.getMessage))
119121
logger.error("Failed to handle RPC call", t)
120-
})
122+
}
121123
case HttpMethod.PUT =>
122124
call.map(handlePut).get
123125
case _ =>

0 commit comments

Comments
 (0)