7094842: test/javax/security/auth/Subject/{Synch.java,Synch2.java,Synch3.java} loop forever in agentvm mode
Reviewed-by: alanb
--- a/jdk/test/javax/security/auth/Subject/Synch.java Fri Sep 23 23:29:56 2011 -0700
+++ b/jdk/test/javax/security/auth/Subject/Synch.java Mon Sep 26 17:13:47 2011 +0800
@@ -35,15 +35,15 @@
import javax.security.auth.x500.X500Principal;
public class Synch {
+ static volatile boolean finished = false;
public static void main(String[] args) {
Subject subject = new Subject();
final Set principals = subject.getPrincipals();
principals.add(new X500Principal("CN=Alice"));
new Thread() {
- { setDaemon(true); }
public void run() {
Principal last = new X500Principal("CN=Bob");
- for (int i = 0; true; i++) {
+ for (int i = 0; !finished; i++) {
Principal next = new X500Principal("CN=Bob" + i);
principals.add(next);
principals.remove(last);
@@ -70,5 +70,6 @@
}
});
}
+ finished = true;
}
}
--- a/jdk/test/javax/security/auth/Subject/Synch2.java Fri Sep 23 23:29:56 2011 -0700
+++ b/jdk/test/javax/security/auth/Subject/Synch2.java Mon Sep 26 17:13:47 2011 +0800
@@ -35,6 +35,7 @@
import javax.security.auth.x500.X500Principal;
public class Synch2 {
+ static volatile boolean finished = false;
public static void main(String[] args) {
System.setSecurityManager(new SecurityManager());
Subject subject = new Subject();
@@ -44,12 +45,11 @@
credentials.add("Dummy credential");
new Thread() {
{
- setDaemon(true);
start();
}
public void run() {
X500Principal p = new X500Principal("CN=Bob");
- while (true) {
+ while (!finished) {
principals.add(p);
principals.remove(p);
}
@@ -62,5 +62,6 @@
}
}
}
+ finished = true;
}
}
--- a/jdk/test/javax/security/auth/Subject/Synch3.java Fri Sep 23 23:29:56 2011 -0700
+++ b/jdk/test/javax/security/auth/Subject/Synch3.java Mon Sep 26 17:13:47 2011 +0800
@@ -33,18 +33,18 @@
import javax.security.auth.x500.X500Principal;
public class Synch3 {
+ static volatile boolean finished = false;
public static void main(String[] args) {
Subject subject = new Subject();
final Set principals = subject.getPrincipals();
principals.add(new X500Principal("CN=Alice"));
new Thread() {
{
- setDaemon(true);
start();
}
public void run() {
X500Principal p = new X500Principal("CN=Bob");
- while (true) {
+ while (!finished) {
principals.add(p);
principals.remove(p);
}
@@ -53,5 +53,6 @@
for (int i = 0; i < 1000; i++) {
subject.getPrincipals(X500Principal.class);
}
+ finished = true;
}
}