The fix revision 935344 was aimed to remove an resource leak bug on the OutputStreamWriter object "writer" (created in line 323) in the method "execute()" of the file "/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java" , but it is incomplete.
There are some problems:
1. when "writer" is not created successfully but the FileOutputStream object "tStream" is created successfully at line 322,"tStream" will be leaked.
The best way to close such resource objects is putting such close operations in the finaly block of a try-catch-finally structure.
The problem still exists in the head revision. The buggy code is copied as bellows:
File targetFile = new File( targetDirectory, "pmd." + format );
357 FileOutputStream tStream = new FileOutputStream( targetFile );
358 writer = new OutputStreamWriter( tStream, getOutputEncoding() );
r.setWriter( writer );
r.renderFileReport( report );
File siteDir = getReportOutputDirectory();
FileUtils.copyFile( targetFile, new File( siteDir, "pmd." + format ) );
catch ( IOException ioe )
throw new MavenReportException( ioe.getMessage(), ioe );
376 IOUtil.close( writer );