maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r698384 - /maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
Date Tue, 23 Sep 2008 22:48:30 GMT
Author: vsiveton
Date: Tue Sep 23 15:48:30 2008
New Revision: 698384

URL: http://svn.apache.org/viewvc?rev=698384&view=rev
Log:
o take care of closing reader

Modified:
    maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java?rev=698384&r1=698383&r2=698384&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
Tue Sep 23 15:48:30 2008
@@ -504,14 +504,13 @@
         InputStream is = null;
         try
         {
-            is = new BufferedInputStream( new FileInputStream( f ) );
-
             if ( isXML( f ) )
             {
                 reader = ReaderFactory.newXmlReader( f );
                 return ( (XmlStreamReader) reader ).getEncoding();
             }
 
+            is = new BufferedInputStream( new FileInputStream( f ) );
             CharsetDetector detector = new CharsetDetector();
             detector.setText( is );
             CharsetMatch match = detector.detect();
@@ -548,10 +547,12 @@
             throw new IllegalArgumentException( "The file '" + f.getAbsolutePath() + "' is
not a file." );
         }
 
+        Reader reader = null;
         try
         {
+            reader = new FileReader( f );
             XmlPullParser parser = new MXParser();
-            parser.setInput( new FileReader( f ) );
+            parser.setInput( reader );
             parser.nextToken();
 
             return true;
@@ -560,6 +561,10 @@
         {
             return false;
         }
+        finally
+        {
+            IOUtil.close( reader );
+        }
     }
 
     /**
@@ -586,7 +591,8 @@
         for ( int i = 0; i < SUPPORTED_FROM_FORMAT.length; i++ )
         {
             // Handle Doxia text files
-            if ( SUPPORTED_FROM_FORMAT[i].equalsIgnoreCase( APT_PARSER ) && isDoxiaFormat(
f, SUPPORTED_FROM_FORMAT[i] ) )
+            if ( SUPPORTED_FROM_FORMAT[i].equalsIgnoreCase( APT_PARSER )
+                && isDoxiaFormat( f, SUPPORTED_FROM_FORMAT[i] ) )
             {
                 return SUPPORTED_FROM_FORMAT[i];
             }



Mime
View raw message