commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kenneth Ritch (JIRA)" <>
Subject [jira] Created: (NET-334) can throw a NullPointerException
Date Thu, 12 Aug 2010 02:44:16 GMT can throw a NullPointerException

                 Key: NET-334
             Project: Commons Net
          Issue Type: Bug
    Affects Versions: 2.0
         Environment: OS: Linux -- Redhat enterprise 
JVM 1.6 64bit 

            Reporter: Kenneth Ritch can throw a NullPointerException
if the 
InputStream is null. This has been experienced on a loaded system. 


Exception in thread "Telnet Reader" java.lang.NullPointerException 


at Source) 
at Source) 
at Source) 
at Source) 
at Source) 
at Source) 


The base PushbackInputStream checks the input stream is not closed before invoking avilable()

274  public int available() throws IOException {
275 	ensureOpen();
276		return (buf.length - pos) + super.available();
277  }

Which throws appropriate IOException if input stream is null: 

72	private void ensureOpen() throws IOException {
73		if (in == null)
74		throw new IOException("Stream closed");
75	} does not. This can lead to a NullPointerException being
thrown if the input stream is null.

191        // PushbackInputStream in JDK 1.1.3 returns the wrong thing
192        /***
193         * Returns the number of bytes that can be read without blocking EXCEPT
194         * when newline conversions have to be made somewhere within the
195         * available block of bytes.  In other words, you really should not
196         * rely on the value returned by this method if you are trying to avoid
197         * blocking.
198         ***/
199        @Override
200        public int available() throws IOException
201        {
202            return (buf.length - pos) + in.available();
203        }

FromNetASCIIInputStream.available() should be changed to mimic the base class behaviour. 

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message