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];
}