commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1539802 - /commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Languages.java
Date Thu, 07 Nov 2013 20:33:56 GMT
Author: ggregory
Date: Thu Nov  7 20:33:55 2013
New Revision: 1539802

URL: http://svn.apache.org/r1539802
Log:
Make sure the scanner is always closed.

Modified:
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Languages.java

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Languages.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Languages.java?rev=1539802&r1=1539801&r2=1539802&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Languages.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Languages.java
Thu Nov  7 20:33:55 2013
@@ -158,20 +158,24 @@ public class Languages {
         }
 
         final Scanner lsScanner = new Scanner(langIS, ResourceConstants.ENCODING);
-        boolean inExtendedComment = false;
-        while (lsScanner.hasNextLine()) {
-            final String line = lsScanner.nextLine().trim();
-            if (inExtendedComment) {
-                if (line.endsWith(ResourceConstants.EXT_CMT_END)) {
-                    inExtendedComment = false;
-                }
-            } else {
-                if (line.startsWith(ResourceConstants.EXT_CMT_START)) {
-                    inExtendedComment = true;
-                } else if (line.length() > 0) {
-                    ls.add(line);
+        try {
+            boolean inExtendedComment = false;
+            while (lsScanner.hasNextLine()) {
+                final String line = lsScanner.nextLine().trim();
+                if (inExtendedComment) {
+                    if (line.endsWith(ResourceConstants.EXT_CMT_END)) {
+                        inExtendedComment = false;
+                    }
+                } else {
+                    if (line.startsWith(ResourceConstants.EXT_CMT_START)) {
+                        inExtendedComment = true;
+                    } else if (line.length() > 0) {
+                        ls.add(line);
+                    }
                 }
             }
+        } finally {
+            lsScanner.close();
         }
 
         return new Languages(Collections.unmodifiableSet(ls));



Mime
View raw message