ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35544] New: - ReaderInputStream.close() should not set members to null
Date Wed, 29 Jun 2005 15:15:20 GMT
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: smarc@gmx.net


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: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message