|
35 | 35 | import java.net.Socket;
|
36 | 36 | import java.net.SocketAddress;
|
37 | 37 | import java.net.SocketException;
|
38 |
| -import java.net.UnknownHostException; |
39 | 38 | import java.nio.ByteBuffer;
|
40 | 39 | import java.util.List;
|
41 | 40 | import java.util.concurrent.TimeUnit;
|
@@ -135,7 +134,7 @@ public final class SSLSocketImpl
|
135 | 134 | * if appropriate.
|
136 | 135 | */
|
137 | 136 | SSLSocketImpl(SSLContextImpl sslContext, String peerHost,
|
138 |
| - int peerPort) throws IOException, UnknownHostException { |
| 137 | + int peerPort) throws IOException { |
139 | 138 | super();
|
140 | 139 | this.sslContext = sslContext;
|
141 | 140 | HandshakeHash handshakeHash = new HandshakeHash();
|
@@ -179,7 +178,7 @@ public final class SSLSocketImpl
|
179 | 178 | */
|
180 | 179 | SSLSocketImpl(SSLContextImpl sslContext,
|
181 | 180 | String peerHost, int peerPort, InetAddress localAddr,
|
182 |
| - int localPort) throws IOException, UnknownHostException { |
| 181 | + int localPort) throws IOException { |
183 | 182 | super();
|
184 | 183 | this.sslContext = sslContext;
|
185 | 184 | HandshakeHash handshakeHash = new HandshakeHash();
|
@@ -1406,11 +1405,9 @@ private int readHandshakeRecord() throws IOException {
|
1406 | 1405 | conContext.isNegotiated) {
|
1407 | 1406 | return 0;
|
1408 | 1407 | }
|
1409 |
| - } catch (SSLException ssle) { |
1410 |
| - throw ssle; |
1411 |
| - } catch (InterruptedIOException iioe) { |
| 1408 | + } catch (SSLException | InterruptedIOException ssle) { |
1412 | 1409 | // don't change exception in case of timeouts or interrupts
|
1413 |
| - throw iioe; |
| 1410 | + throw ssle; |
1414 | 1411 | } catch (IOException ioe) {
|
1415 | 1412 | throw new SSLException("readHandshakeRecord", ioe);
|
1416 | 1413 | }
|
@@ -1471,17 +1468,11 @@ private ByteBuffer readApplicationRecord(
|
1471 | 1468 | buffer.position() > 0) {
|
1472 | 1469 | return buffer;
|
1473 | 1470 | }
|
1474 |
| - } catch (SSLException ssle) { |
1475 |
| - throw ssle; |
1476 |
| - } catch (InterruptedIOException iioe) { |
| 1471 | + } catch (SSLException | InterruptedIOException ssle) { |
1477 | 1472 | // don't change exception in case of timeouts or interrupts
|
1478 |
| - throw iioe; |
| 1473 | + throw ssle; |
1479 | 1474 | } catch (IOException ioe) {
|
1480 |
| - if (!(ioe instanceof SSLException)) { |
1481 |
| - throw new SSLException("readApplicationRecord", ioe); |
1482 |
| - } else { |
1483 |
| - throw ioe; |
1484 |
| - } |
| 1475 | + throw new SSLException("readApplicationRecord", ioe); |
1485 | 1476 | }
|
1486 | 1477 | }
|
1487 | 1478 |
|
@@ -1738,19 +1729,25 @@ public void shutdown() throws IOException {
|
1738 | 1729 | }
|
1739 | 1730 |
|
1740 | 1731 | try {
|
1741 |
| - if (conContext.isInputCloseNotified) { |
1742 |
| - // Close the connection, no wait for more peer response. |
1743 |
| - closeSocket(false); |
1744 |
| - } else { |
1745 |
| - // Close the connection, may wait for peer close_notify. |
1746 |
| - closeSocket(true); |
1747 |
| - } |
| 1732 | + // If conContext.isInputCloseNotified is false, close the |
| 1733 | + // connection, no wait for more peer response. Otherwise, |
| 1734 | + // may wait for peer close_notify. |
| 1735 | + closeSocket(!conContext.isInputCloseNotified); |
1748 | 1736 | } finally {
|
1749 | 1737 | tlsIsClosed = true;
|
1750 | 1738 | }
|
1751 | 1739 | }
|
1752 | 1740 | }
|
1753 | 1741 |
|
| 1742 | + @Override |
| 1743 | + public String toString() { |
| 1744 | + return "SSLSocket[" + |
| 1745 | + "hostname=" + getPeerHost() + |
| 1746 | + ", port=" + getPeerPort() + |
| 1747 | + ", " + conContext.conSession + // SSLSessionImpl.toString() |
| 1748 | + "]"; |
| 1749 | + } |
| 1750 | + |
1754 | 1751 | private void closeSocket(boolean selfInitiated) throws IOException {
|
1755 | 1752 | if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
|
1756 | 1753 | SSLLogger.fine("close the SSL connection " +
|
|
0 commit comments