[ 
https://issues.apache.org/jira/browse/NET-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285341#comment-13285341
 ] 

Gary D. Gregory commented on NET-466:
-------------------------------------

Are you saying that all methods in {{BufferedInputStream}} marked with 
{{synchronized}} should also be marked as such in {{TelnetInputStream}}?

This in TelnetClient is confusing:

{code:java}
protected void _connectAction_() throws IOException
    {
        super._connectAction_();
        TelnetInputStream tmp = new TelnetInputStream(_input_, this, 
readerThread);
        if(readerThread)
        {
            tmp._start();
        }
        // __input CANNOT refer to the TelnetInputStream.  We run into
        // blocking problems when some classes use TelnetInputStream, so
        // we wrap it with a BufferedInputStream which we know is safe.
        // This blocking behavior requires further investigation, but right
        // now it looks like classes like InputStreamReader are not implemented
        // in a safe manner.
        __input = new BufferedInputStream(tmp);
        __output = new TelnetOutputStream(this);
    }
{code}

{{TelnetInputStream}} subclasses {{BufferedInputStream}} and this method wraps 
the {{TelnetInputStream}} in a {{BufferedInputStream}}. Is that what is 
intended here? If so, it needs better docs!
                
> Regression: TelnetInputStream#available() blocks
> ------------------------------------------------
>
>                 Key: NET-466
>                 URL: https://issues.apache.org/jira/browse/NET-466
>             Project: Commons Net
>          Issue Type: Bug
>          Components: Telnet
>    Affects Versions: 3.1
>            Reporter: Martin Oberhuber
>            Priority: Critical
>             Fix For: 3.1
>
>
> When testing with Commons Net 3.1 for Eclipse 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=194473 , I found that our 
> telnet client blocks when the ReaderThread is running and waiting for new 
> data. Investigation shows that our code blocks on 
> TelnetInputStream#available().
> This regression is due to the code introduced for NET-437 "TelnetInputStream 
> doesn't support non-blocking IO when reader thread is not enabled":
> TelnetInputStream#available() now calls super.available() which is declared 
> as "synchronized" on BufferedInputStream in JDK 1.6.0_21 at least. But at the 
> same time, the telnet ReaderThread has already the Monitor on 
> BufferedInputStream and doesn't give it up while sitting in read0().
> This seems to be exactly the situation that the comment before 
> TelnetInputStream#close() warns about:
>     // Cannot be synchronized.  Will cause deadlock if run() is blocked
>     // in read because BufferedInputStream read() is synchronized.
> This is a severe issue since it violates the specification and use of 
> available().

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to