Author: vhennebert
Date: Mon Jul 28 16:57:29 2014
New Revision: 1614076

URL: http://svn.apache.org/r1614076
Log:
BATIK-897: added close() method to free underlying stream used by Scanner

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Parser.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Scanner.java

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Parser.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Parser.java?rev=1614076&r1=1614075&r2=1614076&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Parser.java 
(original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Parser.java Mon 
Jul 28 16:57:29 2014
@@ -236,6 +236,7 @@ public class Parser implements ExtendedP
             }
         } finally {
             documentHandler.endDocument(source);
+            scanner.close();
             scanner = null;
         }
     }
@@ -270,6 +271,7 @@ public class Parser implements ExtendedP
         } catch (CSSParseException e) {
             reportError(e);
         } finally {
+            scanner.close();
             scanner = null;
         }
     }
@@ -290,6 +292,7 @@ public class Parser implements ExtendedP
     protected void parseRuleInternal() throws CSSException, IOException {
         nextIgnoreSpaces();
         parseRule();
+        scanner.close();
         scanner = null;
     }
 
@@ -310,6 +313,7 @@ public class Parser implements ExtendedP
         throws CSSException, IOException {
         nextIgnoreSpaces();
         SelectorList ret = parseSelectorList();
+        scanner.close();
         scanner = null;
         return ret;
     }
@@ -344,6 +348,7 @@ public class Parser implements ExtendedP
         if (current != LexicalUnits.EOF)
             exception = createCSSParseException("eof.expected");
 
+        scanner.close();
         scanner = null;
 
         if (exception != null) {
@@ -369,6 +374,7 @@ public class Parser implements ExtendedP
         throws CSSException, IOException {
         nextIgnoreSpaces();
 
+        scanner.close();
         scanner = null;
 
         switch (current) {

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Scanner.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Scanner.java?rev=1614076&r1=1614075&r2=1614076&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Scanner.java 
(original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/parser/Scanner.java 
Mon Jul 28 16:57:29 2014
@@ -225,6 +225,17 @@ public class Scanner {
     }
 
     /**
+     * Closes the underlying stream used by the scanner.
+     */
+    public void close() {
+        try {
+            reader.close();
+        } catch(IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
      * Returns the end gap of the current lexical unit.
      */
     protected int endGap() {


Reply via email to