QPID-7719: Address review comments
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java
index d53cf06..2472cda 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java
@@ -60,19 +60,27 @@
}
catch (ServerScopedRuntimeException | Error e)
{
- if (_uncaughtExceptionHandler == null)
+ try
{
- LOGGER.error("Fatal system error", e);
+ if (e instanceof ServerScopedRuntimeException
+ && servletResponse instanceof HttpServletResponse
+ && !servletResponse.isCommitted())
+ {
+ ((HttpServletResponse) servletResponse).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
}
- else
+ finally
{
- _uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), e);
+ if (_uncaughtExceptionHandler == null)
+ {
+ LOGGER.error("Fatal system error", e);
+ }
+ else
+ {
+ _uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), e);
+ }
}
- if (e instanceof ServerScopedRuntimeException)
- {
- sendError((ServerScopedRuntimeException)e, servletResponse, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
throw e;
}
catch (ExternalServiceTimeoutException e)