Repository: logging-log4j2
Updated Branches:
  refs/heads/master 52250eb78 -> 4bfd57686


Use try-with-resources.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4bfd5768
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4bfd5768
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4bfd5768

Branch: refs/heads/master
Commit: 4bfd576863fd72ba1eb890c710da20baa23f124f
Parents: 52250eb
Author: Matt Sicker <[email protected]>
Authored: Mon Feb 15 13:07:29 2016 -0600
Committer: Matt Sicker <[email protected]>
Committed: Mon Feb 15 13:07:29 2016 -0600

----------------------------------------------------------------------
 .../core/config/plugins/processor/PluginCache.java      | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4bfd5768/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCache.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCache.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCache.java
index 5e32820..1894754 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCache.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginCache.java
@@ -17,8 +17,6 @@
 
 package org.apache.logging.log4j.core.config.plugins.processor;
 
-import org.apache.logging.log4j.core.util.Closer;
-
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.DataInputStream;
@@ -69,8 +67,7 @@ public class PluginCache {
      */
     // NOTE: if this file format is to be changed, the filename should change 
and this format should still be readable
     public void writeCache(final OutputStream os) throws IOException {
-        final DataOutputStream out = new DataOutputStream(new 
BufferedOutputStream(os));
-        try {
+        try (final DataOutputStream out = new DataOutputStream(new 
BufferedOutputStream(os))) {
             // See PluginManager.readFromCacheFiles for the corresponding 
decoder. Format may not be changed
             // without breaking existing Log4j2Plugins.dat files.
             out.writeInt(categories.size());
@@ -87,8 +84,6 @@ public class PluginCache {
                     out.writeBoolean(plugin.isDefer());
                 }
             }
-        } finally {
-            Closer.closeSilently(out);
         }
     }
 
@@ -102,8 +97,7 @@ public class PluginCache {
         categories.clear();
         while (resources.hasMoreElements()) {
             final URL url = resources.nextElement();
-            final DataInputStream in = new DataInputStream(new 
BufferedInputStream(url.openStream()));
-            try {
+            try (final DataInputStream in = new DataInputStream(new 
BufferedInputStream(url.openStream()))) {
                 final int count = in.readInt();
                 for (int i = 0; i < count; i++) {
                     final String category = in.readUTF();
@@ -122,8 +116,6 @@ public class PluginCache {
                         }
                     }
                 }
-            } finally {
-                Closer.closeSilently(in);
             }
         }
     }

Reply via email to