Skip to content

Commit 1091e80

Browse files
committed
fine to close a socket which is not-yet-connected (like in MRI)
1 parent 47c9f42 commit 1091e80

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/org/jruby/ext/openssl/SSLSocket.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.nio.ByteBuffer;
3333
import java.nio.channels.Channel;
3434
import java.nio.channels.ClosedChannelException;
35+
import java.nio.channels.NotYetConnectedException;
3536
import java.nio.channels.SelectableChannel;
3637
import java.nio.channels.SelectionKey;
3738
import java.nio.channels.Selector;
@@ -40,7 +41,6 @@
4041
import java.security.NoSuchAlgorithmException;
4142
import java.security.cert.Certificate;
4243
import java.security.cert.CertificateEncodingException;
43-
import java.util.Set;
4444

4545
import javax.net.ssl.SSLEngine;
4646
import javax.net.ssl.SSLEngineResult;
@@ -905,8 +905,10 @@ private void close(boolean force) {
905905
try {
906906
doShutdown();
907907
}
908-
catch (IOException e) {
909-
// ignore?
908+
catch (IOException e) { // ignore?
909+
debug(getRuntime(), "SSLSocket.close doShutdown failed", e);
910+
}
911+
catch (NotYetConnectedException e) {
910912
debug(getRuntime(), "SSLSocket.close doShutdown failed", e);
911913
}
912914
}
@@ -1122,7 +1124,7 @@ private SocketChannelImpl socketChannelImpl() {
11221124
throw new IllegalStateException("unknow channel impl: " + channel + " of type " + channel.getClass().getName());
11231125
}
11241126

1125-
private static interface SocketChannelImpl {
1127+
private interface SocketChannelImpl {
11261128

11271129
boolean isOpen() ;
11281130

0 commit comments

Comments
 (0)