[
https://jira.codehaus.org/browse/MPMD-144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Olivier Lamy closed MPMD-144.
-----------------------------
Resolution: Duplicate
Assignee: Olivier Lamy
dupe of MPMD-146
> An incomplete fix for the resource leak bugs in PmdReport.java
> --------------------------------------------------------------
>
> Key: MPMD-144
> URL: https://jira.codehaus.org/browse/MPMD-144
> Project: Maven 2.x PMD Plugin
> Issue Type: Bug
> Components: PMD
> Affects Versions: 2.8
> Reporter: Guangtai Liang
> Assignee: Olivier Lamy
> Priority: Critical
> Attachments:
> 0001-Close-the-fileoutputstream-in-the-finally-block-too..patch
>
>
> 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:
> try
> {
> targetDirectory.mkdirs();
> File targetFile = new File( targetDirectory, "pmd." + format );
> 357 FileOutputStream tStream = new FileOutputStream( targetFile );
> 358 writer = new OutputStreamWriter( tStream, getOutputEncoding()
> );
> r.setWriter( writer );
> r.start();
> r.renderFileReport( report );
> r.end();
> writer.close();
> File siteDir = getReportOutputDirectory();
> siteDir.mkdirs();
> FileUtils.copyFile( targetFile, new File( siteDir, "pmd." +
> format ) );
> }
> catch ( IOException ioe )
> {
> throw new MavenReportException( ioe.getMessage(), ioe );
> }
> finally
> {
> 376 IOUtil.close( writer );
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira