diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java index 7a9ae46c5af5d91421c2a0aba5d7e84d53bd722c..cd6154c96ad5928eddd19b2a01ab755b14e4c731 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl.java @@ -824,7 +824,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 */ public boolean isClosed() { synchronized (_stateLock) { - return _state == State.CLOSED; + return _state == State.CLOSED || _state == State.INIT; } } @@ -835,9 +835,13 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 * @throws I2PSessionException if the message is malformed or there is an error writing it out */ void sendMessage(I2CPMessage message) throws I2PSessionException { - if (isClosed()) { - throw new I2PSessionException("Already closed"); - } else if (_queue != null) { + synchronized (_stateLock) { + if (_state == State.CLOSED) + throw new I2PSessionException("Already closed"); + if (_state == State.INIT) + throw new I2PSessionException("Not open, must call connect() first"); + } + if (_queue != null) { // internal try { if (!_queue.offer(message, MAX_SEND_WAIT)) @@ -846,7 +850,8 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 throw new I2PSessionException("Interrupted", ie); } } else if (_writer == null) { - throw new I2PSessionException("Already closed"); + // race here + throw new I2PSessionException("Already closed or not open"); } else { _writer.addMessage(message); } diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 285b64c36d6c8c56d27bc442c464c5057a7ccb8e..0cd02d33d12e8a5cbd5776e89fe01dcb65d8b49b 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -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 = 28; + public final static long BUILD = 29; /** for example "-test" */ public final static String EXTRA = "-rc";