[jira] Created: (NET-283) SocketClient should ensure input and output streams are closed

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (NET-283) SocketClient should ensure input and output streams are closed

ASF GitHub Bot (Jira)
SocketClient should ensure input and output streams are closed
--------------------------------------------------------------

                 Key: NET-283
                 URL: https://issues.apache.org/jira/browse/NET-283
             Project: Commons Net
          Issue Type: Improvement
    Affects Versions: 2.0
         Environment: All
            Reporter: Theuns Cloete


From the Java 6 SDK, the socket.close() method is responsible for also closing its input and output streams. But if socket.close() throws an IOException before the streams could be closed, the streams will remain open and they will also not be set to null. We need a way to ensure that the input and output streams are also closed. There are various ways to achieve this:

Proposal 1:
Implement a public SocketClient.paranoidDisconnect() method that makes sure the socket, input and output are closed:
public void paranoidDisconnect() {
try { this.disconnect(); }
catch (IOException ioe) {
// the first thing that SocketClient.disconnect() does is to close the socket
// but if that fails, we have to manually close the input and output streams
if (this.input != null) {
try { this._input_.close(); }
catch (IOException ioe2) {
}
}

if (this.output != null) {
try { this._output_.close(); }
catch (IOException ioe3) {
}
}
}
finally { this._socket_ = null; this._input_ = null; this._output_ = null; }
}

Proposal 2:
Expose the socket, input and output stream objects with getter methods at the SocketClient level, handing the responsibility over to the calling application. TelnetClient already exposes the input and output streams with getInputStream() and getOutputStream() methods respectively.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (NET-283) SocketClient should ensure input and output streams are closed

ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/NET-283?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved NET-283.
----------------------

    Fix Version/s: 2.1
       Resolution: Fixed

> SocketClient should ensure input and output streams are closed
> --------------------------------------------------------------
>
>                 Key: NET-283
>                 URL: https://issues.apache.org/jira/browse/NET-283
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 2.0
>         Environment: All
>            Reporter: Theuns Cloete
>             Fix For: 2.1
>
>
> From the Java 6 SDK, the socket.close() method is responsible for also closing its input and output streams. But if socket.close() throws an IOException before the streams could be closed, the streams will remain open and they will also not be set to null. We need a way to ensure that the input and output streams are also closed. There are various ways to achieve this:
> Proposal 1:
> Implement a public SocketClient.paranoidDisconnect() method that makes sure the socket, input and output are closed:
> public void paranoidDisconnect() {
> try { this.disconnect(); }
> catch (IOException ioe) {
> // the first thing that SocketClient.disconnect() does is to close the socket
> // but if that fails, we have to manually close the input and output streams
> if (this.input != null) {
> try { this._input_.close(); }
> catch (IOException ioe2) {
> }
> }
> if (this.output != null) {
> try { this._output_.close(); }
> catch (IOException ioe3) {
> }
> }
> }
> finally { this._socket_ = null; this._input_ = null; this._output_ = null; }
> }
> Proposal 2:
> Expose the socket, input and output stream objects with getter methods at the SocketClient level, handing the responsibility over to the calling application. TelnetClient already exposes the input and output streams with getInputStream() and getOutputStream() methods respectively.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (NET-283) SocketClient should ensure input and output streams are closed

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Theuns Cloete commented on NET-283:
-----------------------------------

How exactly was this issue resolved?

> SocketClient should ensure input and output streams are closed
> --------------------------------------------------------------
>
>                 Key: NET-283
>                 URL: https://issues.apache.org/jira/browse/NET-283
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 2.0
>         Environment: All
>            Reporter: Theuns Cloete
>             Fix For: 2.1
>
>
> From the Java 6 SDK, the socket.close() method is responsible for also closing its input and output streams. But if socket.close() throws an IOException before the streams could be closed, the streams will remain open and they will also not be set to null. We need a way to ensure that the input and output streams are also closed. There are various ways to achieve this:
> Proposal 1:
> Implement a public SocketClient.paranoidDisconnect() method that makes sure the socket, input and output are closed:
> public void paranoidDisconnect() {
> try { this.disconnect(); }
> catch (IOException ioe) {
> // the first thing that SocketClient.disconnect() does is to close the socket
> // but if that fails, we have to manually close the input and output streams
> if (this.input != null) {
> try { this._input_.close(); }
> catch (IOException ioe2) {
> }
> }
> if (this.output != null) {
> try { this._output_.close(); }
> catch (IOException ioe3) {
> }
> }
> }
> finally { this._socket_ = null; this._input_ = null; this._output_ = null; }
> }
> Proposal 2:
> Expose the socket, input and output stream objects with getter methods at the SocketClient level, handing the responsibility over to the calling application. TelnetClient already exposes the input and output streams with getInputStream() and getOutputStream() methods respectively.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (NET-283) SocketClient should ensure input and output streams are closed

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Sebb commented on NET-283:
--------------------------

Check the Subversion Commits history tab for details of the change applied

> SocketClient should ensure input and output streams are closed
> --------------------------------------------------------------
>
>                 Key: NET-283
>                 URL: https://issues.apache.org/jira/browse/NET-283
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 2.0
>         Environment: All
>            Reporter: Theuns Cloete
>             Fix For: 2.1
>
>
> From the Java 6 SDK, the socket.close() method is responsible for also closing its input and output streams. But if socket.close() throws an IOException before the streams could be closed, the streams will remain open and they will also not be set to null. We need a way to ensure that the input and output streams are also closed. There are various ways to achieve this:
> Proposal 1:
> Implement a public SocketClient.paranoidDisconnect() method that makes sure the socket, input and output are closed:
> public void paranoidDisconnect() {
> try { this.disconnect(); }
> catch (IOException ioe) {
> // the first thing that SocketClient.disconnect() does is to close the socket
> // but if that fails, we have to manually close the input and output streams
> if (this.input != null) {
> try { this._input_.close(); }
> catch (IOException ioe2) {
> }
> }
> if (this.output != null) {
> try { this._output_.close(); }
> catch (IOException ioe3) {
> }
> }
> }
> finally { this._socket_ = null; this._input_ = null; this._output_ = null; }
> }
> Proposal 2:
> Expose the socket, input and output stream objects with getter methods at the SocketClient level, handing the responsibility over to the calling application. TelnetClient already exposes the input and output streams with getInputStream() and getOutputStream() methods respectively.

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