Skip to content

Commit 28a89ce

Browse files
committed
Refactor processResponseError in ServerRuntime
Signed-off-by: Maxim Nesen <[email protected]>
1 parent aea2d4b commit 28a89ce

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -460,6 +460,8 @@ private boolean processResponseError(final Throwable responseError) {
460460
final Iterable<ResponseErrorMapper> mappers = Providers.getAllProviders(runtime.injectionManager,
461461
ResponseErrorMapper.class);
462462

463+
ContainerResponse processedResponse = null;
464+
463465
try {
464466
Response processedError = null;
465467
for (final ResponseErrorMapper mapper : mappers) {
@@ -470,11 +472,16 @@ private boolean processResponseError(final Throwable responseError) {
470472
}
471473

472474
if (processedError != null) {
473-
processResponse(new ContainerResponse(processingContext.request(), processedError));
475+
processedResponse =
476+
processResponse(new ContainerResponse(processingContext.request(), processedError));
474477
processed = true;
475478
}
476479
} catch (final Throwable throwable) {
477480
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_EXCEPTION_MAPPING_PROCESSED_RESPONSE_ERROR(), throwable);
481+
} finally {
482+
if (processedResponse != null) {
483+
release(processedResponse);
484+
}
478485
}
479486
}
480487

0 commit comments

Comments
 (0)