summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2015-04-07 18:29:37 +0100
committerSergio Giro <sgiro@google.com>2015-04-08 14:28:56 +0100
commit7c4f30cf50079df52bc4572688c7c9eed129a4bb (patch)
tree184c37b22b0b610322ac16325948a42647ca0833 /support
parentf180cb21b5bd3e5fa314a5e259f192b663e72216 (diff)
downloadlibcore-7c4f30cf50079df52bc4572688c7c9eed129a4bb.zip
libcore-7c4f30cf50079df52bc4572688c7c9eed129a4bb.tar.gz
libcore-7c4f30cf50079df52bc4572688c7c9eed129a4bb.tar.bz2
libcore: change SSLEngineTest to close SSLEngine instances
It was leaking resources allocated by SSLEngine's, pipes among others, thus causing subsequent tests to fail with "too many open files" errors. In OpenSSLEngineImpl, the resources are freed in the finalizer, so there's no guarantee that resources as pipes will ever be freed unless the engines are explicitly closed. Change-Id: Ide90808a64278486a19bcdfcba628f623c62afc9
Diffstat (limited to 'support')
-rw-r--r--support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java b/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java
index 6c2c943..3a12629 100644
--- a/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java
+++ b/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
+import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import junit.framework.Assert;
@@ -134,6 +135,23 @@ public final class TestSSLEnginePair extends Assert {
void beforeBeginHandshake(SSLEngine client, SSLEngine server) {}
}
+ public void close() throws SSLException {
+ close(new SSLEngine[] { client, server });
+ }
+
+ public static void close(SSLEngine[] engines) {
+ try {
+ for (SSLEngine engine : engines) {
+ if (engine != null) {
+ engine.closeInbound();
+ engine.closeOutbound();
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
private static boolean handshakeCompleted(SSLEngine engine,
ByteBuffer output,
ByteBuffer input,