提交 aa3bf2c9 编写于 作者: I igerasim

8144313: Test SessionTimeOutTests can be timeout

Reviewed-by: mullan
上级 19d4067e
/* /*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2015, 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.
*/ */
...@@ -116,7 +117,7 @@ public class SessionTimeOutTests { ...@@ -116,7 +117,7 @@ public class SessionTimeOutTests {
/* /*
* 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 +138,7 @@ public class SessionTimeOutTests { ...@@ -137,7 +138,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 +146,7 @@ public class SessionTimeOutTests { ...@@ -145,7 +146,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);
} }
...@@ -447,7 +448,7 @@ public class SessionTimeOutTests { ...@@ -447,7 +448,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 +460,7 @@ public class SessionTimeOutTests { ...@@ -459,7 +460,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.
先完成此消息的编辑!
想要评论请 注册