On Sun, Nov 16, 2008 at 7:26 PM, Joakim Erdfelt <[EMAIL PROTECTED]> wrote:
> You should put that reader.close() in the finally{} block of the try/catch.
> If the MavenXpp3Reader fails, or the FileReader fails on IO read, then the
> file is still not closed.
Yep, you're right. I did not look closely enough at the MavenXpp3Reader API.
Thanks for catching it.
--
Martin Cooper
/* typical pattern */
> FileReader reader = null;
> try {
> reader = new FileReader(file);
> // Do something with the reader.
> } finally {
> if(reader != null) {
> reader.close();
> }
> }
>
> - Joakim
>
>
> [EMAIL PROTECTED] wrote:
>
>> Author: jdumay
>> Date: Sun Nov 16 17:39:20 2008
>> New Revision: 718157
>>
>> URL: http://svn.apache.org/viewvc?rev=718157&view=rev
>> Log:
>> MRM-1004 - RepositoryServlet tests fail intermittently on Windows.
>> Submitted by Martin Cooper.
>>
>>
>> Modified:
>>
>>
>> archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
>>
>> Modified:
>> archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
>> URL:
>> http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java?rev=718157&r1=718156&r2=718157&view=diff
>>
>> ==============================================================================
>> ---
>> archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
>> (original)
>> +++
>> archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
>> Sun Nov 16 17:39:20 2008
>> @@ -587,7 +587,11 @@
>> try
>> {
>> - Model model = new MavenXpp3Reader().read( new FileReader( pom
>> ) );
>> + // MavenXpp3Reader leaves the file open, so we need to close
>> it ourselves.
>> + FileReader reader = new FileReader( pom );
>> + Model model = new MavenXpp3Reader().read( reader );
>> + reader.close();
>> +
>> DistributionManagement dist =
>> model.getDistributionManagement();
>> if ( dist != null )
>> {
>>
>>
>>
>>
>
>
> --
> - Joakim Erdfelt
> [EMAIL PROTECTED]
> Open Source Software (OSS) Developer
>
>