org.apache.commons.net.io.FromNetASCIIInputStream can throw a
NullPointerException
----------------------------------------------------------------------------------
Key: NET-334
URL: https://issues.apache.org/jira/browse/NET-334
Project: Commons Net
Issue Type: Bug
Affects Versions: 2.0
Environment: OS: Linux -- Redhat enterprise
JVM 1.6 64bit
Reporter: Kenneth Ritch
org.apache.commons.net.io.FromNetASCIIInputStream.available() can throw a
NullPointerException if the
InputStream is null. This has been experienced on a loaded system.
StackTrace:
Exception in thread "Telnet Reader" java.lang.NullPointerException
at
org.apache.commons.net.io.FromNetASCIIInputStream.available(FromNetASCIIInputStream.java:202)
at
org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:164)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at
org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:122)
at
org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:375)
at
org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:492)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
Cause:
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 }
commons.net.io.FromNetASCIIInputStream 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.