diff options
Diffstat (limited to 'src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java')
-rw-r--r-- | src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java b/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java index d05717d..1c55bc6 100644 --- a/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java +++ b/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java @@ -41,10 +41,10 @@ public abstract class I2PSamStateMachine implements Closeable { public abstract boolean connect(); protected boolean connect(Socket samSocket) { - this.samSocket = samSocket; if (this.connected) { throw new IllegalStateException(); } + this.samSocket = samSocket; this.connected = true; return true; } @@ -207,7 +207,9 @@ public abstract class I2PSamStateMachine implements Closeable { * @throws IOException As per {@link Socket#close()}. */ public void close() throws IOException { - this.samSocket.close(); + if (this.connected) { + this.samSocket.close(); + } } protected Socket unwrap() { |