Author: pottlinger
Date: Wed May 20 19:03:44 2015
New Revision: 1680654

URL: http://svn.apache.org/r1680654
Log:
RAT-171: Ensure Buffered reader is closed properly.

* Remove unused variable.

Modified:
    
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java
    
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ScmIgnoreParser.java

Modified: 
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java
URL: 
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java?rev=1680654&r1=1680653&r2=1680654&view=diff
==============================================================================
--- 
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java
 (original)
+++ 
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java
 Wed May 20 19:03:44 2015
@@ -23,7 +23,6 @@ import org.apache.rat.api.Document;
 import org.apache.rat.api.MetaData;
 import org.apache.rat.document.MockLocation;
 import org.apache.rat.license.ILicenseFamily;
-import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -41,13 +40,11 @@ public class DefaultPolicyTest {
         }
     };
 
-    private MockClaimReporter reporter;
     private Document subject;
     private DefaultPolicy policy;
 
     @Before
     public void setUp() throws Exception {
-        reporter = new MockClaimReporter();
         policy = new DefaultPolicy();
         subject = new MockLocation("subject");
     }

Modified: 
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ScmIgnoreParser.java
URL: 
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ScmIgnoreParser.java?rev=1680654&r1=1680653&r2=1680654&view=diff
==============================================================================
--- 
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ScmIgnoreParser.java
 (original)
+++ 
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ScmIgnoreParser.java
 Wed May 20 19:03:44 2015
@@ -42,7 +42,6 @@ public final class ScmIgnoreParser {
 
     private static List<String> COMMENT_PREFIXES = Arrays.asList("#", "##", 
"//", "/**", "/*");
 
-    // FIXME: RAT-171 should we try to parse it into Patterns to sort out 
error cases?
     /**
      * Parses excludes from the given SCM ignore file.
      *
@@ -52,12 +51,13 @@ public final class ScmIgnoreParser {
      */
     public static List<String> getExcludesFromFile(final Log log, final File 
scmIgnore) {
 
-        List<String> exclusionLines = new ArrayList<String>();
+        final List<String> exclusionLines = new ArrayList<String>();
 
         if (scmIgnore != null && scmIgnore.exists() && scmIgnore.isFile()) {
             log.info("Parsing exclusions from " + scmIgnore);
+            BufferedReader reader = null;
             try {
-                final BufferedReader reader = new BufferedReader(new 
FileReader(scmIgnore));
+                reader = new BufferedReader(new FileReader(scmIgnore));
                 String line;
                 while ((line = reader.readLine()) != null) {
                     if (!isComment(line)) {
@@ -68,12 +68,20 @@ public final class ScmIgnoreParser {
             } catch (final IOException e) {
                 log.warn("Cannot parse " + scmIgnore + " for exclusions. Will 
skip this file.");
                 log.debug("Skip parsing " + scmIgnore + " due to " + 
e.getMessage());
+            } finally {
+                if (reader != null) {
+                    try {
+                        reader.close();
+                    } catch (IOException e) {
+                        log.error("Cannot close " + scmIgnore + " after 
exclusion parsing. Will give up.");
+                    }
+                }
+
             }
         }
         return exclusionLines;
     }
 
-
     /**
      * Parse ignore files from all known SCMs that have ignore files.
      *


Reply via email to