[
https://jira.codehaus.org/browse/MPMD-145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andreas Dangel updated MPMD-145:
--------------------------------
Attachment: 0001-Close-the-readers-in-a-finally-block-MPMD-145.patch
> An incomplete fix for the resource leak bugs in PmdReportTest.java
> ------------------------------------------------------------------
>
> Key: MPMD-145
> URL: https://jira.codehaus.org/browse/MPMD-145
> Project: Maven 2.x PMD Plugin
> Issue Type: Bug
> Components: PMD
> Affects Versions: 2.8
> Reporter: Guangtai Liang
> Priority: Critical
> Attachments: 0001-Close-the-readers-in-a-finally-block-MPMD-145.patch
>
>
> The fix revision 729532 was aimed to remove an resource leak bug on the
> BufferedReader object "in" (created in line 240) in the method "readFile()"
> of the file "/maven/plugins/trunk/maven-pmd-
> plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java" , but it
> is incomplete.
> There are some problems:
> 1. when "in" is not created successfully but the temp FileReader object is
> created successfully at line 240,the temp FileReader object 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:
> private String readFile( File file )
> throws IOException
> {
> String strTmp;
> StringBuffer str = new StringBuffer( (int) file.length() );
> 246 BufferedReader in = new BufferedReader( new FileReader( file ) );
> while ( ( strTmp = in.readLine() ) != null )
> {
> str.append( ' ' );
> str.append( strTmp );
> }
> 253 in.close();
> return str.toString();
> }
--
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