de.netseeker.ejoe.io
Class ChannelInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by de.netseeker.ejoe.io.ChannelInputStream
All Implemented Interfaces:
java.io.Closeable

public class ChannelInputStream
extends java.io.FilterInputStream

This is a very ugly try to work around the following issue when using Channel.newInputStream(): If the client closes the connection and we are already reading from the blocking InputStream, that stream will simply throw an IOException to notify us of the connection close. Because channel.isOpen() as well as the corresponding socket methods will not immediately tell us that the socket is closed we have no chance to decide if the IOException was thrown because the socket was closed by client or if there occured an IOException in the reader of the InputStream. To avoid that annoying issue we use this FilterInputStream which just wraps all IOExceptions into a NonReadableChannelException to tell us that the socket is not readable anymore.

Since:
0.3.2
Author:
netseeker

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ChannelInputStream(java.io.InputStream in)
           
 
Method Summary
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelInputStream

public ChannelInputStream(java.io.InputStream in)
Parameters:
in -
Method Detail

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException


Copyright © 2005-2007 netseeker. All Rights Reserved.