提交 0f080bcf 编写于 作者: A asaha

Merge

...@@ -594,6 +594,7 @@ f6cc9dbb5db5883385c91bb71ca02081220aaf3d jdk8u81-b00 ...@@ -594,6 +594,7 @@ f6cc9dbb5db5883385c91bb71ca02081220aaf3d jdk8u81-b00
25934d0d38fe10383ff22eb3f39bf5e8b9e73ac9 jdk8u101-b03 25934d0d38fe10383ff22eb3f39bf5e8b9e73ac9 jdk8u101-b03
ebc56c2e803597ef409a5296addc986b390d934d jdk8u101-b04 ebc56c2e803597ef409a5296addc986b390d934d jdk8u101-b04
c387bd2fb7db40467bd9aa803c8510a04ca32bae jdk8u101-b05 c387bd2fb7db40467bd9aa803c8510a04ca32bae jdk8u101-b05
a15cdf2e91e7c2d71510280b31ae11048fb2f31e jdk8u101-b06
39baa472e20c13c0eb1243eb5dce589e82f78143 jdk8u76-b00 39baa472e20c13c0eb1243eb5dce589e82f78143 jdk8u76-b00
6ea3aea950d19d803475b3f4d704a2942e71b302 jdk8u76-b01 6ea3aea950d19d803475b3f4d704a2942e71b302 jdk8u76-b01
4de4cffb5988cd68959ce4bbd14c6d4547078c91 jdk8u76-b02 4de4cffb5988cd68959ce4bbd14c6d4547078c91 jdk8u76-b02
......
/* /*
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2016, 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
...@@ -35,6 +35,7 @@ import java.io.*; ...@@ -35,6 +35,7 @@ import java.io.*;
import java.net.*; import java.net.*;
import javax.net.ssl.*; import javax.net.ssl.*;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.security.KeyStore; import java.security.KeyStore;
public class SSLCtxAccessToSessCtx { public class SSLCtxAccessToSessCtx {
...@@ -63,7 +64,7 @@ public class SSLCtxAccessToSessCtx { ...@@ -63,7 +64,7 @@ public class SSLCtxAccessToSessCtx {
/* /*
* Is the server ready to serve? * Is the server ready to serve?
*/ */
volatile static boolean serverReady = false; AtomicInteger serverReady = new AtomicInteger(1); // only one port now
/* /*
* Turn on SSL debugging? * Turn on SSL debugging?
...@@ -89,12 +90,13 @@ public class SSLCtxAccessToSessCtx { ...@@ -89,12 +90,13 @@ public class SSLCtxAccessToSessCtx {
SSLServerSocket sslServerSocket = SSLServerSocket sslServerSocket =
(SSLServerSocket) sslssf.createServerSocket(serverPort); (SSLServerSocket) sslssf.createServerSocket(serverPort);
serverPorts[createdPorts++] = sslServerSocket.getLocalPort(); int slot = createdPorts.getAndIncrement();
serverPorts[slot] = sslServerSocket.getLocalPort();
/* /*
* Signal Client, we're ready for his connect. * Signal Client, we're ready for his connect.
*/ */
serverReady = true; serverReady.getAndDecrement();
int read = 0; int read = 0;
SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
InputStream sslIS = sslSocket.getInputStream(); InputStream sslIS = sslSocket.getInputStream();
...@@ -121,7 +123,7 @@ public class SSLCtxAccessToSessCtx { ...@@ -121,7 +123,7 @@ public class SSLCtxAccessToSessCtx {
/* /*
* Wait for server to get started. * Wait for server to get started.
*/ */
while (!serverReady) { while (serverReady.get() > 0) {
Thread.sleep(50); Thread.sleep(50);
} }
/* /*
...@@ -151,8 +153,8 @@ public class SSLCtxAccessToSessCtx { ...@@ -151,8 +153,8 @@ public class SSLCtxAccessToSessCtx {
* The remainder is just support stuff * The remainder is just support stuff
*/ */
volatile int serverPorts[] = new int[]{0}; int serverPorts[] = new int[]{0}; // only one port at present
volatile int createdPorts = 0; AtomicInteger createdPorts = new AtomicInteger(0);
static SSLServerSocketFactory sslssf; static SSLServerSocketFactory sslssf;
static SSLSocketFactory sslsf; static SSLSocketFactory sslsf;
static SSLContext sslctx; static SSLContext sslctx;
...@@ -255,14 +257,20 @@ public class SSLCtxAccessToSessCtx { ...@@ -255,14 +257,20 @@ public class SSLCtxAccessToSessCtx {
*/ */
System.err.println("Server died..."); System.err.println("Server died...");
e.printStackTrace(); e.printStackTrace();
serverReady = true; serverReady.set(0);
serverException = e; serverException = e;
} }
} }
}; };
serverThread.start(); serverThread.start();
} else { } else {
doServerSide(port); try {
doServerSide(port);
} catch (Exception e) {
serverException = e;
} finally {
serverReady.set(0);
}
} }
} }
...@@ -284,7 +292,11 @@ public class SSLCtxAccessToSessCtx { ...@@ -284,7 +292,11 @@ public class SSLCtxAccessToSessCtx {
}; };
clientThread.start(); clientThread.start();
} else { } else {
doClientSide(); try {
doClientSide();
} catch (Exception e) {
clientException = e;
}
} }
} }
} }
/* /*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2016, 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
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
/* /*
* @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
*/ */
...@@ -108,36 +108,47 @@ public class SessionCacheSizeTests { ...@@ -108,36 +108,47 @@ public class SessionCacheSizeTests {
void doServerSide(int serverPort, int serverConns) throws Exception { void doServerSide(int serverPort, int serverConns) throws Exception {
SSLServerSocket sslServerSocket = try (SSLServerSocket sslServerSocket =
(SSLServerSocket) sslssf.createServerSocket(serverPort); (SSLServerSocket) sslssf.createServerSocket(serverPort)) {
serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
/* // timeout to accept a connection
* Signal Client, we're ready for his connect. sslServerSocket.setSoTimeout(45000);
*/
if (createdPorts == serverPorts.length) { // make sure createdPorts++ is atomic
serverReady = true; synchronized(serverPorts) {
} serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
int read = 0;
int nConnections = 0; /*
/* * Signal Client, we're ready for his connect.
* Divide the max connections among the available server ports. */
* The use of more than one server port ensures creation of more if (createdPorts == serverPorts.length) {
* than one session. serverReady = true;
*/ }
SSLSession sessions [] = new SSLSession [serverConns]; }
SSLSessionContext sessCtx = sslctx.getServerSessionContext(); int read = 0;
int nConnections = 0;
while (nConnections < serverConns) {
SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); /*
InputStream sslIS = sslSocket.getInputStream(); * Divide the max connections among the available server ports.
OutputStream sslOS = sslSocket.getOutputStream(); * The use of more than one server port ensures creation of more
read = sslIS.read(); * than one session.
sessions[nConnections] = sslSocket.getSession(); */
sslOS.write(85); SSLSession sessions [] = new SSLSession [serverConns];
sslOS.flush(); SSLSessionContext sessCtx = sslctx.getServerSessionContext();
sslSocket.close();
nConnections++; while (nConnections < serverConns) {
try (SSLSocket sslSocket =
(SSLSocket)sslServerSocket.accept()) {
sslSocket.setSoTimeout(90000); // timeout to read
InputStream sslIS = sslSocket.getInputStream();
OutputStream sslOS = sslSocket.getOutputStream();
read = sslIS.read();
sessions[nConnections] = sslSocket.getSession();
sslOS.write(85);
sslOS.flush();
nConnections++;
}
}
} }
} }
...@@ -263,8 +274,8 @@ public class SessionCacheSizeTests { ...@@ -263,8 +274,8 @@ public class SessionCacheSizeTests {
* Using four ports (one per each connection), we are able to create * Using four ports (one per each connection), we are able to create
* alteast four sessions. * alteast four sessions.
*/ */
volatile int serverPorts[] = new int[]{0, 0, 0, 0}; int serverPorts[] = new int[]{0, 0, 0, 0}; // MAX_ACTIVE_CONNECTIONS: 4
volatile int createdPorts = 0; int createdPorts = 0;
static SSLServerSocketFactory sslssf; static SSLServerSocketFactory sslssf;
static SSLSocketFactory sslsf; static SSLSocketFactory sslsf;
static SSLContext sslctx; static SSLContext sslctx;
......
/* /*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2016, 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
...@@ -36,6 +36,7 @@ import java.net.*; ...@@ -36,6 +36,7 @@ import java.net.*;
import javax.net.ssl.*; import javax.net.ssl.*;
import java.util.*; import java.util.*;
import java.security.*; import java.security.*;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* Session reuse time-out tests cover the cases below: * Session reuse time-out tests cover the cases below:
...@@ -79,7 +80,7 @@ public class SessionTimeOutTests { ...@@ -79,7 +80,7 @@ public class SessionTimeOutTests {
/* /*
* Is the server ready to serve? * Is the server ready to serve?
*/ */
volatile static int serverReady = PORTS; AtomicInteger serverReady = new AtomicInteger(PORTS);
/* /*
* Turn on SSL debugging? * Turn on SSL debugging?
...@@ -98,7 +99,7 @@ public class SessionTimeOutTests { ...@@ -98,7 +99,7 @@ public class SessionTimeOutTests {
/* /*
* Define the server side of the test. * Define the server side of the test.
* *
* If the server prematurely exits, serverReady will be set to true * If the server prematurely exits, serverReady will be set to zero
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
...@@ -111,12 +112,13 @@ public class SessionTimeOutTests { ...@@ -111,12 +112,13 @@ public class SessionTimeOutTests {
SSLServerSocket sslServerSocket = SSLServerSocket sslServerSocket =
(SSLServerSocket) sslssf.createServerSocket(serverPort); (SSLServerSocket) sslssf.createServerSocket(serverPort);
serverPorts[createdPorts++] = sslServerSocket.getLocalPort(); int slot = createdPorts.getAndIncrement();
serverPorts[slot] = sslServerSocket.getLocalPort();
/* /*
* Signal Client, we're ready for his connect. * Signal Client, we're ready for his connect.
*/ */
serverReady--; serverReady.getAndDecrement();
int read = 0; int read = 0;
int nConnections = 0; int nConnections = 0;
SSLSession sessions [] = new SSLSession [serverConns]; SSLSession sessions [] = new SSLSession [serverConns];
...@@ -137,7 +139,7 @@ public class SessionTimeOutTests { ...@@ -137,7 +139,7 @@ public class SessionTimeOutTests {
/* /*
* Define the client side of the test. * Define the client side of the test.
* *
* If the server prematurely exits, serverReady will be set to true * If the server prematurely exits, serverReady will be set to zero
* to avoid infinite hangs. * to avoid infinite hangs.
*/ */
void doClientSide() throws Exception { void doClientSide() throws Exception {
...@@ -145,7 +147,7 @@ public class SessionTimeOutTests { ...@@ -145,7 +147,7 @@ public class SessionTimeOutTests {
/* /*
* Wait for server to get started. * Wait for server to get started.
*/ */
while (serverReady > 0) { while (serverReady.get() > 0) {
Thread.sleep(50); Thread.sleep(50);
} }
...@@ -287,8 +289,8 @@ public class SessionTimeOutTests { ...@@ -287,8 +289,8 @@ public class SessionTimeOutTests {
* The remainder is just support stuff * The remainder is just support stuff
*/ */
volatile int serverPorts[] = new int[PORTS]; int serverPorts[] = new int[PORTS];
volatile int createdPorts = 0; AtomicInteger createdPorts = new AtomicInteger(0);
static SSLServerSocketFactory sslssf; static SSLServerSocketFactory sslssf;
static SSLSocketFactory sslsf; static SSLSocketFactory sslsf;
static SSLContext sslctx; static SSLContext sslctx;
...@@ -447,7 +449,7 @@ public class SessionTimeOutTests { ...@@ -447,7 +449,7 @@ public class SessionTimeOutTests {
*/ */
System.err.println("Server died..."); System.err.println("Server died...");
e.printStackTrace(); e.printStackTrace();
serverReady = 0; serverReady.set(0);
serverException = e; serverException = e;
} }
} }
...@@ -459,7 +461,7 @@ public class SessionTimeOutTests { ...@@ -459,7 +461,7 @@ public class SessionTimeOutTests {
} catch (Exception e) { } catch (Exception e) {
serverException = e; serverException = e;
} finally { } finally {
serverReady = 0; serverReady.set(0);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册