You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Guangtai Liang (JIRA)" <ji...@codehaus.org> on 2012/02/22 09:06:02 UTC

[jira] (MPMD-145) An incomplete fix for the resource leak bugs in PmdReportTest.java

Guangtai Liang created MPMD-145:
-----------------------------------

             Summary: 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


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

        

[jira] (MPMD-145) An incomplete fix for the resource leak bugs in PmdReportTest.java

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
     [ https://jira.codehaus.org/browse/MPMD-145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Olivier Lamy closed MPMD-145.
-----------------------------

       Resolution: Fixed
    Fix Version/s: 2.8
         Assignee: Olivier Lamy

fixed.
Thanks !
                
> 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
>            Assignee: Olivier Lamy
>            Priority: Critical
>             Fix For: 2.8
>
>         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

        

[jira] (MPMD-145) An incomplete fix for the resource leak bugs in PmdReportTest.java

Posted by "Andreas Dangel (JIRA)" <ji...@codehaus.org>.
     [ 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