You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2022/01/03 20:52:39 UTC

[logging-log4j2] 01/02: Use try-with-resources

This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 25d88be893b920f6ab1e3523d711dc61bd4f3bef
Author: Matt Sicker <ma...@apache.org>
AuthorDate: Mon Jan 3 14:06:58 2022 -0600

    Use try-with-resources
    
    Signed-off-by: Matt Sicker <ma...@apache.org>
---
 .../apache/logging/log4j/plugins/spi/impl/InjectionTargetBean.java    | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/impl/InjectionTargetBean.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/impl/InjectionTargetBean.java
index c64aa32..06ab925 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/impl/InjectionTargetBean.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/impl/InjectionTargetBean.java
@@ -59,12 +59,10 @@ class InjectionTargetBean<T> extends AbstractBean<T> {
 
     @Override
     public void destroy(final T instance, final InitializationContext<T> context) {
-        try {
+        try (context) {
             if (isDependentScoped()) {
                 injectionTarget.preDestroy(instance);
             }
-        } finally {
-            context.close();
         }
     }