Skip to content

Commit fb7b95f

Browse files
SentryManrbygrave
andauthored
Avoid sending headers twice on write error (#194)
* Avoid sending headers twice on write error * Format only --------- Co-authored-by: Rob Bygrave <[email protected]>
1 parent 023d5cd commit fb7b95f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

avaje-jex/src/main/java/io/avaje/jex/core/ExceptionManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ private void unhandledException(JdkContext ctx, Exception e) {
5656
}
5757

5858
private void defaultHandling(JdkContext ctx, HttpResponseException exception) {
59+
if (ctx.responseSent()) {
60+
// if already sent headers, can't send again
61+
return;
62+
}
63+
5964
ctx.status(exception.status());
6065
var jsonResponse = exception.jsonResponse();
6166
if (exception.status() == HttpStatus.FOUND_302.status()) {

0 commit comments

Comments
 (0)