[java-metadata-aggregator] branch main updated: Simplify by refactoring using try-with-resources

Ian Young ian at iay.org.uk
Wed Aug 19 15:52:03 UTC 2020


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch main
in repository java-metadata-aggregator.

View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=7bd70139f309814fe25c1deadac451095a5ae39f

The following commit(s) were added to refs/heads/main by this push:
       new  7bd7013   Simplify by refactoring using try-with-resources
7bd7013 is described below

commit 7bd70139f309814fe25c1deadac451095a5ae39f
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed Aug 19 16:51:59 2020 +0100

    Simplify by refactoring using try-with-resources
---
 .../shibboleth/metadata/dom/DOMFilesystemSourceStage.java  | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java
index 68d4ef4..c3121e5 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMFilesystemSourceStage.java
@@ -20,7 +20,6 @@ package net.shibboleth.metadata.dom;
 import java.io.File;
 import java.io.FileFilter;
 import java.io.FileInputStream;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -277,11 +276,8 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
      *             {@link #errorCausesSourceFailure} is true
      */
     @Nonnull protected DOMElementItem processSourceFile(@Nonnull final File source) throws StageProcessingException {
-        FileInputStream xmlIn = null;
-
-        try {
-            log.debug("{} pipeline source parsing XML file {}", getId(), source.getPath());
-            xmlIn = new FileInputStream(source);
+        log.debug("{} pipeline source parsing XML file {}", getId(), source.getPath());
+        try (FileInputStream xmlIn = new FileInputStream(source)) {
             final Document doc = getParserPool().parse(xmlIn);
             return new DOMElementItem(doc);
         } catch (final Exception e) {
@@ -292,12 +288,6 @@ public class DOMFilesystemSourceStage extends AbstractStage<Element> {
             log.warn("{} pipeline source: unable to parse XML source file {}, ignoring it bad file", new Object[] {
                     getId(), source.getPath(), e,});
             return null;
-        } finally {
-            try {
-                xmlIn.close();
-            } catch (final IOException e) {
-                throw new StageProcessingException("Exception closing input stream", e);
-            }
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list