You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Eric Fitchett (JIRA)" <ji...@apache.org> on 2007/02/09 01:44:05 UTC

[jira] Created: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
--------------------------------------------------------------------------------------

                 Key: DIRMINA-347
                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
             Project: MINA
          Issue Type: Bug
          Components: Core
    Affects Versions: 1.0.1
         Environment: Ubuntu 6.06
            Reporter: Eric Fitchett
            Priority: Minor


When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}

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


[jira] Updated: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Posted by "Eric Fitchett (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Fitchett updated DIRMINA-347:
----------------------------------

    Attachment: StreamIoHandler_CloseStreams.diff

Patch attached to fix this problem, created off the 1.0 branch.

> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-347
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.1
>         Environment: Ubuntu 6.06
>            Reporter: Eric Fitchett
>            Priority: Minor
>         Attachments: StreamIoHandler_CloseStreams.diff
>
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.
>     protected final void processStreamIo(
>             IoSession session,
>             InputStream in,
>             OutputStream out) {
>         sessionStreams.put(session, in);
>         // Process the streams in a separate thread
>         new Worker(in, out).start();
>     }
>     // Ensures session's InputStream gets closed, so the thread doesn't lock up
>     private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
>     @Override
>     public void sessionClosed(IoSession session) throws Exception {
>         super.sessionClosed(session);
>         InputStream is = sessionStreams.get(session);
>         if(null != is) {
>             try {
>                 is.close();
>             } catch(IOException ioe) {
>                 // Ignore
>             }
>         }
>     }

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


[jira] Closed: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny closed DIRMINA-347.
-------------------------------------


> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-347
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.1
>         Environment: Ubuntu 6.06
>            Reporter: Eric Fitchett
>            Assignee: Trustin Lee
>            Priority: Minor
>             Fix For: 1.0.2
>
>         Attachments: StreamIoHandler_CloseStreams.diff
>
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.
>     protected final void processStreamIo(
>             IoSession session,
>             InputStream in,
>             OutputStream out) {
>         sessionStreams.put(session, in);
>         // Process the streams in a separate thread
>         new Worker(in, out).start();
>     }
>     // Ensures session's InputStream gets closed, so the thread doesn't lock up
>     private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
>     @Override
>     public void sessionClosed(IoSession session) throws Exception {
>         super.sessionClosed(session);
>         InputStream is = sessionStreams.get(session);
>         if(null != is) {
>             try {
>                 is.close();
>             } catch(IOException ioe) {
>                 // Ignore
>             }
>         }
>     }

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


[jira] Resolved: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trustin Lee resolved DIRMINA-347.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 1.0.2
         Assignee: Trustin Lee

Your patch has been applied to all branches.  Thanks!

> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-347
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.1
>         Environment: Ubuntu 6.06
>            Reporter: Eric Fitchett
>         Assigned To: Trustin Lee
>            Priority: Minor
>             Fix For: 1.0.2
>
>         Attachments: StreamIoHandler_CloseStreams.diff
>
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.
>     protected final void processStreamIo(
>             IoSession session,
>             InputStream in,
>             OutputStream out) {
>         sessionStreams.put(session, in);
>         // Process the streams in a separate thread
>         new Worker(in, out).start();
>     }
>     // Ensures session's InputStream gets closed, so the thread doesn't lock up
>     private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
>     @Override
>     public void sessionClosed(IoSession session) throws Exception {
>         super.sessionClosed(session);
>         InputStream is = sessionStreams.get(session);
>         if(null != is) {
>             try {
>                 is.close();
>             } catch(IOException ioe) {
>                 // Ignore
>             }
>         }
>     }

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


[jira] Updated: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Posted by "Eric Fitchett (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Fitchett updated DIRMINA-347:
----------------------------------

    Description: 
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

    protected final void processStreamIo(
            IoSession session,
            InputStream in,
            OutputStream out) {
        sessionStreams.put(session, in);
        // Process the streams in a separate thread
        new Worker(in, out).start();
    }
    // Ensures session's InputStream gets closed, so the thread doesn't lock up
    private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
    @Override
    public void sessionClosed(IoSession session) throws Exception {
        super.sessionClosed(session);
        InputStream is = sessionStreams.get(session);
        if(null != is) {
            try {
                is.close();
            } catch(IOException ioe) {
                // Ignore
            }
        }
    }

  was:
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}


> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-347
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.1
>         Environment: Ubuntu 6.06
>            Reporter: Eric Fitchett
>            Priority: Minor
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.
>     protected final void processStreamIo(
>             IoSession session,
>             InputStream in,
>             OutputStream out) {
>         sessionStreams.put(session, in);
>         // Process the streams in a separate thread
>         new Worker(in, out).start();
>     }
>     // Ensures session's InputStream gets closed, so the thread doesn't lock up
>     private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
>     @Override
>     public void sessionClosed(IoSession session) throws Exception {
>         super.sessionClosed(session);
>         InputStream is = sessionStreams.get(session);
>         if(null != is) {
>             try {
>                 is.close();
>             } catch(IOException ioe) {
>                 // Ignore
>             }
>         }
>     }

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


[jira] Updated: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Posted by "Eric Fitchett (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Fitchett updated DIRMINA-347:
----------------------------------

    Description: 
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

<code>
	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}
</code>

  was:
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}


> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-347
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.1
>         Environment: Ubuntu 6.06
>            Reporter: Eric Fitchett
>            Priority: Minor
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.
> <code>
> 	protected final void processStreamIo(
> 			IoSession session,
> 			InputStream in,
> 			OutputStream out) {
> 		sessionStreams.put(session, in);
> 		// Process the streams in a separate thread
> 		new Worker(in, out).start();
> 	}
> 	// Ensures session's InputStream gets closed, so the thread doesn't lock up
> 	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
> 	@Override
> 	public void sessionClosed(IoSession session) throws Exception {
> 		super.sessionClosed(session);
> 		InputStream is = sessionStreams.get(session);
> 		if(null != is) {
> 			try {
> 				is.close();
> 			} catch(IOException ioe) {
> 				// Ignore
> 			}
> 		}
> 	}
> </code>

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


[jira] Updated: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Posted by "Eric Fitchett (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Fitchett updated DIRMINA-347:
----------------------------------

    Description: 
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

<pre>
	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}
</pre>

  was:
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

<code>
	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}
</code>


> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-347
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.1
>         Environment: Ubuntu 6.06
>            Reporter: Eric Fitchett
>            Priority: Minor
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.
> <pre>
> 	protected final void processStreamIo(
> 			IoSession session,
> 			InputStream in,
> 			OutputStream out) {
> 		sessionStreams.put(session, in);
> 		// Process the streams in a separate thread
> 		new Worker(in, out).start();
> 	}
> 	// Ensures session's InputStream gets closed, so the thread doesn't lock up
> 	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
> 	@Override
> 	public void sessionClosed(IoSession session) throws Exception {
> 		super.sessionClosed(session);
> 		InputStream is = sessionStreams.get(session);
> 		if(null != is) {
> 			try {
> 				is.close();
> 			} catch(IOException ioe) {
> 				// Ignore
> 			}
> 		}
> 	}
> </pre>

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


[jira] Updated: (DIRMINA-347) Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()

Posted by "Eric Fitchett (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Fitchett updated DIRMINA-347:
----------------------------------

    Description: 
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}

  was:
When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.

I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.

<pre>
	protected final void processStreamIo(
			IoSession session,
			InputStream in,
			OutputStream out) {
		sessionStreams.put(session, in);
		// Process the streams in a separate thread
		new Worker(in, out).start();
	}
	// Ensures session's InputStream gets closed, so the thread doesn't lock up
	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		super.sessionClosed(session);
		InputStream is = sessionStreams.get(session);
		if(null != is) {
			try {
				is.close();
			} catch(IOException ioe) {
				// Ignore
			}
		}
	}
</pre>


> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-347
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-347
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.1
>         Environment: Ubuntu 6.06
>            Reporter: Eric Fitchett
>            Priority: Minor
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method.  The InputStream remains open, waiting for more data.  After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem.  In the mean time, a workaround I am currently using follows.  It keeps track of the InputStream for each session, and closes it when the session closes.  This ensures the thread has a chance to terminate properly.
> 	protected final void processStreamIo(
> 			IoSession session,
> 			InputStream in,
> 			OutputStream out) {
> 		sessionStreams.put(session, in);
> 		// Process the streams in a separate thread
> 		new Worker(in, out).start();
> 	}
> 	// Ensures session's InputStream gets closed, so the thread doesn't lock up
> 	private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
> 	@Override
> 	public void sessionClosed(IoSession session) throws Exception {
> 		super.sessionClosed(session);
> 		InputStream is = sessionStreams.get(session);
> 		if(null != is) {
> 			try {
> 				is.close();
> 			} catch(IOException ioe) {
> 				// Ignore
> 			}
> 		}
> 	}

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