@@ -130,6 +130,14 @@ public class ServerRuntime {
130
130
/** Resolve relative URIs according to RFC7231 (not JAX-RS 2.0 compliant */
131
131
private final boolean rfc7231LocationHeaderRelativeUriResolution ;
132
132
133
+ /**
134
+ * Cached value of configuration property
135
+ * {@link org.glassfish.jersey.server.ServerProperties#RESPONSE_SET_STATUS_OVER_SEND_ERROR}.
136
+ * If {@code true} method {@link ServerRuntime.CompletionCallbackRunner#onComplete(Throwable)}
137
+ * is used over {@link DefaultExceptionMapper#toResponse(Throwable)}.
138
+ */
139
+ private final boolean configSetStatusOverSendError ;
140
+
133
141
/**
134
142
* Default exception mapper (@since 3.1.0 according to JAX-RS 3.1 spec)
135
143
*/
@@ -197,6 +205,9 @@ private ServerRuntime(final Stage<RequestProcessingContext> requestProcessingRoo
197
205
this .rfc7231LocationHeaderRelativeUriResolution = ServerProperties .getValue (configuration .getProperties (),
198
206
ServerProperties .LOCATION_HEADER_RELATIVE_URI_RESOLUTION_RFC7231 ,
199
207
Boolean .FALSE , Boolean .class );
208
+
209
+ this .configSetStatusOverSendError = ServerProperties .getValue (configuration .getProperties (),
210
+ ServerProperties .RESPONSE_SET_STATUS_OVER_SEND_ERROR , false , Boolean .class );
200
211
}
201
212
202
213
/**
@@ -452,15 +463,17 @@ public void process(final Throwable throwable) {
452
463
453
464
if (!processResponseError (responseError )) {
454
465
// Pass the exception to the container.
455
- LOGGER .log (Level .WARNING , LocalizationMessages .ERROR_EXCEPTION_MAPPING_THROWN_TO_CONTAINER (), responseError );
456
-
457
466
try {
458
467
request .getResponseWriter ().failure (responseError );
459
468
} finally {
460
- defaultMapperResponse = processResponseWithDefaultExceptionMapper (responseError , request );
461
-
462
- // completionCallbackRunner.onComplete(responseError); is called from
463
- // processResponseWithDefaultExceptionMapper
469
+ if (runtime .configSetStatusOverSendError ) {
470
+ completionCallbackRunner .onComplete (responseError );
471
+ } else {
472
+ LOGGER .log (Level .WARNING ,
473
+ LocalizationMessages .ERROR_EXCEPTION_MAPPING_THROWN_TO_CONTAINER (),
474
+ responseError );
475
+ defaultMapperResponse = processResponseWithDefaultExceptionMapper (responseError , request );
476
+ }
464
477
}
465
478
466
479
}
0 commit comments