8022228: Intermittent test failures in sun/security/ssl/javax/net/ssl/NewAPIs
Reviewed-by: weijun
This commit is contained in:
parent
c9443a8346
commit
cac8b88f48
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -21,14 +21,16 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// SunJSSE does not support dynamic system properties, no way to re-use
|
||||||
|
// system properties in samevm/agentvm mode.
|
||||||
|
//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4366807
|
* @bug 4366807
|
||||||
* @summary Need new APIs to get/set session timeout and session cache size.
|
* @summary Need new APIs to get/set session timeout and session cache size.
|
||||||
* @run main/othervm SessionCacheSizeTests
|
* @run main/othervm SessionCacheSizeTests
|
||||||
*
|
|
||||||
* SunJSSE does not support dynamic system properties, no way to re-use
|
|
||||||
* system properties in samevm/agentvm mode.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -113,7 +115,9 @@ public class SessionCacheSizeTests {
|
|||||||
/*
|
/*
|
||||||
* Signal Client, we're ready for his connect.
|
* Signal Client, we're ready for his connect.
|
||||||
*/
|
*/
|
||||||
|
if (createdPorts == serverPorts.length) {
|
||||||
serverReady = true;
|
serverReady = true;
|
||||||
|
}
|
||||||
int read = 0;
|
int read = 0;
|
||||||
int nConnections = 0;
|
int nConnections = 0;
|
||||||
/*
|
/*
|
||||||
@ -310,7 +314,6 @@ public class SessionCacheSizeTests {
|
|||||||
* Fork off the other side, then do your work.
|
* Fork off the other side, then do your work.
|
||||||
*/
|
*/
|
||||||
SessionCacheSizeTests() throws Exception {
|
SessionCacheSizeTests() throws Exception {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create the SSLServerSocket and SSLSocket factories
|
* create the SSLServerSocket and SSLSocket factories
|
||||||
*/
|
*/
|
||||||
@ -323,10 +326,12 @@ public class SessionCacheSizeTests {
|
|||||||
int serverConns = MAX_ACTIVE_CONNECTIONS / (serverPorts.length);
|
int serverConns = MAX_ACTIVE_CONNECTIONS / (serverPorts.length);
|
||||||
int remainingConns = MAX_ACTIVE_CONNECTIONS % (serverPorts.length);
|
int remainingConns = MAX_ACTIVE_CONNECTIONS % (serverPorts.length);
|
||||||
|
|
||||||
|
Exception startException = null;
|
||||||
|
try {
|
||||||
if (separateServerThread) {
|
if (separateServerThread) {
|
||||||
for (int i = 0; i < serverPorts.length; i++) {
|
for (int i = 0; i < serverPorts.length; i++) {
|
||||||
|
// distribute remaining connections among the
|
||||||
// distribute remaining connections among the available ports
|
// available ports
|
||||||
if (i < remainingConns)
|
if (i < remainingConns)
|
||||||
startServer(serverPorts[i], (serverConns + 1), true);
|
startServer(serverPorts[i], (serverConns + 1), true);
|
||||||
else
|
else
|
||||||
@ -342,27 +347,66 @@ public class SessionCacheSizeTests {
|
|||||||
startServer(serverPorts[i], serverConns, false);
|
startServer(serverPorts[i], serverConns, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
startException = e;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for other side to close down.
|
* Wait for other side to close down.
|
||||||
*/
|
*/
|
||||||
if (separateServerThread) {
|
if (separateServerThread) {
|
||||||
|
if (serverThread != null) {
|
||||||
serverThread.join();
|
serverThread.join();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (clientThread != null) {
|
||||||
clientThread.join();
|
clientThread.join();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When we get here, the test is pretty much over.
|
* When we get here, the test is pretty much over.
|
||||||
*
|
|
||||||
* If the main thread excepted, that propagates back
|
|
||||||
* immediately. If the other thread threw an exception, we
|
|
||||||
* should report back.
|
|
||||||
*/
|
*/
|
||||||
if (serverException != null)
|
Exception local;
|
||||||
throw serverException;
|
Exception remote;
|
||||||
if (clientException != null)
|
|
||||||
throw clientException;
|
if (separateServerThread) {
|
||||||
|
remote = serverException;
|
||||||
|
local = clientException;
|
||||||
|
} else {
|
||||||
|
remote = clientException;
|
||||||
|
local = serverException;
|
||||||
|
}
|
||||||
|
|
||||||
|
Exception exception = null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check various exception conditions.
|
||||||
|
*/
|
||||||
|
if ((local != null) && (remote != null)) {
|
||||||
|
// If both failed, return the curthread's exception.
|
||||||
|
local.initCause(remote);
|
||||||
|
exception = local;
|
||||||
|
} else if (local != null) {
|
||||||
|
exception = local;
|
||||||
|
} else if (remote != null) {
|
||||||
|
exception = remote;
|
||||||
|
} else if (startException != null) {
|
||||||
|
exception = startException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there was an exception *AND* a startException,
|
||||||
|
* output it.
|
||||||
|
*/
|
||||||
|
if (exception != null) {
|
||||||
|
if (exception != startException && startException != null) {
|
||||||
|
exception.addSuppressed(startException);
|
||||||
|
}
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall-through: no exception to throw!
|
||||||
}
|
}
|
||||||
|
|
||||||
void startServer(final int port, final int nConns,
|
void startServer(final int port, final int nConns,
|
||||||
@ -387,7 +431,13 @@ public class SessionCacheSizeTests {
|
|||||||
};
|
};
|
||||||
serverThread.start();
|
serverThread.start();
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
doServerSide(port, nConns);
|
doServerSide(port, nConns);
|
||||||
|
} catch (Exception e) {
|
||||||
|
serverException = e;
|
||||||
|
} finally {
|
||||||
|
serverReady = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +459,11 @@ public class SessionCacheSizeTests {
|
|||||||
};
|
};
|
||||||
clientThread.start();
|
clientThread.start();
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
doClientSide();
|
doClientSide();
|
||||||
|
} catch (Exception e) {
|
||||||
|
clientException = e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -21,14 +21,14 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// SunJSSE does not support dynamic system properties, no way to re-use
|
||||||
|
// system properties in samevm/agentvm mode.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4366807
|
* @bug 4366807
|
||||||
* @summary Need new APIs to get/set session timeout and session cache size.
|
* @summary Need new APIs to get/set session timeout and session cache size.
|
||||||
* @run main/othervm SessionTimeOutTests
|
* @run main/othervm SessionTimeOutTests
|
||||||
*
|
|
||||||
* SunJSSE does not support dynamic system properties, no way to re-use
|
|
||||||
* system properties in samevm/agentvm mode.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -348,9 +348,12 @@ public class SessionTimeOutTests {
|
|||||||
int serverConns = MAX_ACTIVE_CONNECTIONS / (serverPorts.length);
|
int serverConns = MAX_ACTIVE_CONNECTIONS / (serverPorts.length);
|
||||||
int remainingConns = MAX_ACTIVE_CONNECTIONS % (serverPorts.length);
|
int remainingConns = MAX_ACTIVE_CONNECTIONS % (serverPorts.length);
|
||||||
|
|
||||||
|
Exception startException = null;
|
||||||
|
try {
|
||||||
if (separateServerThread) {
|
if (separateServerThread) {
|
||||||
for (int i = 0; i < serverPorts.length; i++) {
|
for (int i = 0; i < serverPorts.length; i++) {
|
||||||
// distribute remaining connections among the available ports
|
// distribute remaining connections among the
|
||||||
|
// vailable ports
|
||||||
if (i < remainingConns)
|
if (i < remainingConns)
|
||||||
startServer(serverPorts[i], (serverConns + 1), true);
|
startServer(serverPorts[i], (serverConns + 1), true);
|
||||||
else
|
else
|
||||||
@ -366,27 +369,67 @@ public class SessionTimeOutTests {
|
|||||||
startServer(serverPorts[i], serverConns, false);
|
startServer(serverPorts[i], serverConns, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
startException = e;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for other side to close down.
|
* Wait for other side to close down.
|
||||||
*/
|
*/
|
||||||
if (separateServerThread) {
|
if (separateServerThread) {
|
||||||
|
if (serverThread != null) {
|
||||||
serverThread.join();
|
serverThread.join();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (clientThread != null) {
|
||||||
clientThread.join();
|
clientThread.join();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When we get here, the test is pretty much over.
|
* When we get here, the test is pretty much over.
|
||||||
*
|
* Which side threw the error?
|
||||||
* If the main thread excepted, that propagates back
|
|
||||||
* immediately. If the other thread threw an exception, we
|
|
||||||
* should report back.
|
|
||||||
*/
|
*/
|
||||||
if (serverException != null)
|
Exception local;
|
||||||
throw serverException;
|
Exception remote;
|
||||||
if (clientException != null)
|
|
||||||
throw clientException;
|
if (separateServerThread) {
|
||||||
|
remote = serverException;
|
||||||
|
local = clientException;
|
||||||
|
} else {
|
||||||
|
remote = clientException;
|
||||||
|
local = serverException;
|
||||||
|
}
|
||||||
|
|
||||||
|
Exception exception = null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check various exception conditions.
|
||||||
|
*/
|
||||||
|
if ((local != null) && (remote != null)) {
|
||||||
|
// If both failed, return the curthread's exception.
|
||||||
|
local.initCause(remote);
|
||||||
|
exception = local;
|
||||||
|
} else if (local != null) {
|
||||||
|
exception = local;
|
||||||
|
} else if (remote != null) {
|
||||||
|
exception = remote;
|
||||||
|
} else if (startException != null) {
|
||||||
|
exception = startException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there was an exception *AND* a startException,
|
||||||
|
* output it.
|
||||||
|
*/
|
||||||
|
if (exception != null) {
|
||||||
|
if (exception != startException && startException != null) {
|
||||||
|
exception.addSuppressed(startException);
|
||||||
|
}
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall-through: no exception to throw!
|
||||||
}
|
}
|
||||||
|
|
||||||
void startServer(final int port, final int nConns,
|
void startServer(final int port, final int nConns,
|
||||||
@ -411,7 +454,13 @@ public class SessionTimeOutTests {
|
|||||||
};
|
};
|
||||||
serverThread.start();
|
serverThread.start();
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
doServerSide(port, nConns);
|
doServerSide(port, nConns);
|
||||||
|
} catch (Exception e) {
|
||||||
|
serverException = e;
|
||||||
|
} finally {
|
||||||
|
serverReady = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +482,11 @@ public class SessionTimeOutTests {
|
|||||||
};
|
};
|
||||||
clientThread.start();
|
clientThread.start();
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
doClientSide();
|
doClientSide();
|
||||||
|
} catch (Exception e) {
|
||||||
|
clientException = e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ public class SSLSocketTemplate {
|
|||||||
* output it.
|
* output it.
|
||||||
*/
|
*/
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
if (exception != startException) {
|
if (exception != startException && startException != null) {
|
||||||
exception.addSuppressed(startException);
|
exception.addSuppressed(startException);
|
||||||
}
|
}
|
||||||
throw exception;
|
throw exception;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user