commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joc...@apache.org
Subject svn commit: r1760691 - in /commons/proper/codec/trunk/src: changes/changes.xml main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java main/java/org/apache/commons/codec/language/bm/Rule.java
Date Wed, 14 Sep 2016 12:14:26 GMT
Author: jochen
Date: Wed Sep 14 12:14:26 2016
New Revision: 1760691

URL: http://svn.apache.org/viewvc?rev=1760691&view=rev
Log:
PR: CODEC-225

Fix minor resource leaks. GitHub PR

Modified:
    commons/proper/codec/trunk/src/changes/changes.xml
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java

Modified: commons/proper/codec/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/changes/changes.xml?rev=1760691&r1=1760690&r2=1760691&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/changes/changes.xml (original)
+++ commons/proper/codec/trunk/src/changes/changes.xml Wed Sep 14 12:14:26 2016
@@ -45,6 +45,7 @@ The <action> type attribute can be add,u
     <release version="1.11" date="2016-MM-DD" description="Feature and fix release.">
       <!-- The first attribute below should be the issue id; makes it easier to navigate
in the IDE outline -->
 
+	  <action issue="CODEC-225" dev="jochen" type="fix" due-to="Svetlin Zarev">Fix minor
resource leaks</action>
       <action issue="CODEC-223" dev="sebb" type="remove">Drop obsolete Ant build</action>
       <action issue="CODEC-171" dev="sebb" type="add" due-to="Brett Okken">Add support
for CRC32-C</action>
       <action issue="CODEC-221" dev="sebb" type="update">HmacUtils.updateHmac calls
reset() unnecessarily</action>

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java?rev=1760691&r1=1760690&r2=1760691&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
Wed Sep 14 12:14:26 2016
@@ -232,8 +232,11 @@ public class DaitchMokotoffSoundex imple
         }
 
         final Scanner scanner = new Scanner(rulesIS, CharEncoding.UTF_8);
-        parseRules(scanner, RESOURCE_FILE, RULES, FOLDINGS);
-        scanner.close();
+        try {
+            parseRules(scanner, RESOURCE_FILE, RULES, FOLDINGS);
+        } finally {
+            scanner.close();
+        }
 
         // sort RULES by pattern length in descending order
         for (final Map.Entry<Character, List<Rule>> rule : RULES.entrySet())
{

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java?rev=1760691&r1=1760690&r2=1760691&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
Wed Sep 14 12:14:26 2016
@@ -219,14 +219,22 @@ public class Rule {
 
                 final Languages ls = Languages.getInstance(s);
                 for (final String l : ls.getLanguages()) {
+                    final Scanner scanner = createScanner(s, rt, l);
                     try {
-                        rs.put(l, parseRules(createScanner(s, rt, l), createResourceName(s,
rt, l)));
+                        rs.put(l, parseRules(scanner, createResourceName(s, rt, l)));
                     } catch (final IllegalStateException e) {
                         throw new IllegalStateException("Problem processing " + createResourceName(s,
rt, l), e);
+                    } finally {
+                        scanner.close();
                     }
                 }
                 if (!rt.equals(RuleType.RULES)) {
-                    rs.put("common", parseRules(createScanner(s, rt, "common"), createResourceName(s,
rt, "common")));
+                    final Scanner scanner = createScanner(s, rt, "common");
+                    try {
+                        rs.put("common", parseRules(scanner, createResourceName(s, rt, "common")));
+                    } finally {
+                        scanner.close();
+                    }
                 }
 
                 rts.put(rt, Collections.unmodifiableMap(rs));
@@ -435,7 +443,12 @@ public class Rule {
                             throw new IllegalArgumentException("Malformed import statement
'" + rawLine + "' in " +
                                                                location);
                         }
-                        lines.putAll(parseRules(createScanner(incl), location + "->" +
incl));
+                        final Scanner hashIncludeScanner = createScanner(incl);
+                        try {
+                            lines.putAll(parseRules(hashIncludeScanner, location + "->"
+ incl));
+                        } finally {
+                            hashIncludeScanner.close();
+                        }
                     } else {
                         // rule
                         final String[] parts = line.split("\\s+");



Mime
View raw message