DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35544>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35544

           Summary: ReaderInputStream.close() should not set members to null
           Product: Ant
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: [EMAIL PROTECTED]


This is the code of close() in org.apache.tools.ant.util.ReaderInputStream:

    public synchronized void close() throws IOException {
        in.close();
        slack = null;
        in = null;
    }

The problem comes from setting in to null (in = null, third statement). If one
call the close() method twice, a NullPointerException is thrown the second time!
This should not happen according to the contract of InputStream.close().

Following scenario shows a situation where this is problematic:

public void example(  )
{
        InputStream ins = null;
        
        try
        {
                // do something with ins
                // ...
                
                ins.close();
                
                // further processing
                // ...
                
        }
        catch( IOException e )
        {
                e.printStackTrace();
        }
        finally
        {
                // here comes the problem: a NullPointerException is thrown!!!
                IOUtils.closeQuietly( ins );
        }
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to