diff options
author | Brian Carlstrom <bdc@google.com> | 2011-01-30 17:34:32 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-01-30 17:34:32 -0800 |
commit | f4ee864696462080c24a79f7d412b678a875bbcd (patch) | |
tree | 1c77c571f84fbe9a23fa163b8ad1456294ded3b9 /luni/src | |
parent | 7374d4fa11bad613cb64938c2f189d7907d5b6f8 (diff) | |
parent | b2d079d59f40de0f5570e1c8156a4777aa784828 (diff) | |
download | libcore-f4ee864696462080c24a79f7d412b678a875bbcd.zip libcore-f4ee864696462080c24a79f7d412b678a875bbcd.tar.gz libcore-f4ee864696462080c24a79f7d412b678a875bbcd.tar.bz2 |
am b2d079d5: am aa2be6b8: SSLSocket.close() should not throw an IOException if there is a problem sending a close notify
* commit 'b2d079d59f40de0f5570e1c8156a4777aa784828':
SSLSocket.close() should not throw an IOException if there is a problem sending a close notify
Diffstat (limited to 'luni/src')
-rw-r--r-- | luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java index 35346a2..79bf6e7 100644 --- a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java +++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java @@ -936,6 +936,50 @@ public class SSLSocketTest extends TestCase { server.close(); } + /** + * b/3350645 Test to confirm that an SSLSocket.close() performing + * an SSL_shutdown does not throw an IOException if the peer + * socket has been closed. + */ + public void test_SSLSocket_shutdownCloseOnClosedPeer() throws Exception { + TestSSLContext c = TestSSLContext.create(); + final Socket underlying = new Socket(c.host, c.port); + final SSLSocket wrapping = (SSLSocket) + c.clientContext.getSocketFactory().createSocket(underlying, + c.host.getHostName(), + c.port, + false); + Thread clientThread = new Thread(new Runnable () { + public void run() { + try { + try { + wrapping.startHandshake(); + wrapping.getOutputStream().write(42); + // close the underlying socket, + // so that no SSL shutdown is sent + underlying.close(); + wrapping.close(); + } catch (SSLException expected) { + } + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + clientThread.start(); + + SSLSocket server = (SSLSocket) c.serverSocket.accept(); + server.startHandshake(); + server.getInputStream().read(); + // wait for thread to finish so we know client is closed. + clientThread.join(); + // close should cause an SSL_shutdown which will fail + // because the peer has closed, but it shouldn't throw. + server.close(); + } + public void test_SSLSocket_setSoTimeout_basic() throws Exception { ServerSocket listening = new ServerSocket(0); |