archiva-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joakim Erdfelt <joa...@erdfelt.com>
Subject Re: svn commit: r718157 - /archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
Date Mon, 17 Nov 2008 03:26:59 GMT
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.

/* typical pattern */
FileReader reader = null;
try {
  reader = new FileReader(file);
  // Do something with the reader.
} finally {
  if(reader != null) {
    reader.close();
  }
}

- Joakim

jdumay@apache.org 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
  joakim@erdfelt.com
  Open Source Software (OSS) Developer


Mime
View raw message