* Streaming: Throw IOE if socket is closed (ticket #1077),

never return null from stream getters
This commit is contained in:
zzz
2013-10-17 13:39:00 +00:00
parent 5f7a761e42
commit 255ebe7efb
4 changed files with 26 additions and 12 deletions

View File

@@ -25,13 +25,19 @@ public interface I2PSocket extends Closeable {
public Destination getPeerDestination();
/**
* @return an InputStream to read from the socket.
* As of 0.9.9 will throw an IOE if socket is closed.
* Prior to that would return null instead of throwing IOE.
*
* @return an InputStream to read from the socket. Non-null since 0.9.9.
* @throws IOException on failure
*/
public InputStream getInputStream() throws IOException;
/**
* @return an OutputStream to write into the socket.
* As of 0.9.9 will throw an IOE if socket is closed.
* Prior to that would return null instead of throwing IOE.
*
* @return an OutputStream to write into the socket. Non-null since 0.9.9.
* @throws IOException on failure
*/
public OutputStream getOutputStream() throws IOException;

View File

@@ -67,15 +67,15 @@ class I2PSocketFull implements I2PSocket {
Connection getConnection() { return _connection; }
/**
* Warning, may return null instead of throwing IOE,
* which is not what the interface says.
* As of 0.9.9 will throw an IOE if socket is closed.
* Prior to that would return null instead of throwing IOE.
* @return non-null
*/
public InputStream getInputStream() {
public InputStream getInputStream() throws IOException {
Connection c = _connection;
if (c != null)
return c.getInputStream();
else
return null;
throw new IOException("Socket closed");
}
public I2PSocketOptions getOptions() {
@@ -96,15 +96,15 @@ class I2PSocketFull implements I2PSocket {
}
/**
* Warning, may return null instead of throwing IOE,
* which is not what the interface says.
* As of 0.9.9 will throw an IOE if socket is closed.
* Prior to that would return null instead of throwing IOE.
* @return non-null
*/
public OutputStream getOutputStream() throws IOException {
Connection c = _connection;
if (c != null)
return c.getOutputStream();
else
return null;
throw new IOException("Socket closed");
}
public Destination getPeerDestination() { return _remotePeer; }

View File

@@ -1,3 +1,11 @@
2013-10-17 zzz
* I2CP: Move SSL client socket code to util,
move cert location to certificates/i2cp.
* I2PTunnel: Support SSL for connection to local server
for Standard, HTTP, and IRC server tunnels.
Put server cert in certificates/i2ptunnel if necessary.
* Streaming: Throw IOE if socket is closed (ticket #1077)
2013-10-14 kytv
* French translation updates from Transifex

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 4;
public final static long BUILD = 5;
/** for example "-test" */
public final static String EXTRA = "";