author | dcubed |
Tue, 22 Jun 2010 10:54:59 -0700 | |
changeset 5964 | 0496aa46ae9f |
parent 5506 | 202f599c92aa |
child 14683 | 38921a46c62d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
26 |
* @bug 6467152 6716076 6829503 |
2 | 27 |
* @summary deadlock occurs in LogManager initialization and JVM termination |
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
28 |
* @author Serguei Spitsyn / Hitachi / Martin Buchholz |
2 | 29 |
* |
30 |
* @build LoggingDeadlock2 |
|
31 |
* @run main/timeout=15 LoggingDeadlock2 |
|
32 |
* |
|
33 |
* There is a clear deadlock between LogManager.<clinit> and |
|
34 |
* Cleaner.run() methods. |
|
35 |
* T1 thread: |
|
36 |
* The LogManager.<clinit> creates LogManager.manager object, |
|
37 |
* sets shutdown hook with the Cleaner class and then waits |
|
38 |
* to lock the LogManager.manager monitor. |
|
39 |
* T2 thread: |
|
40 |
* It is started by the System.exit() as shutdown hook thread. |
|
41 |
* It locks the LogManager.manager monitor and then calls the |
|
42 |
* static methods of the LogManager class (in this particular |
|
43 |
* case it is a trick of the inner classes implementation). |
|
44 |
* It is waits when the LogManager.<clinit> is completed. |
|
45 |
* |
|
46 |
* This is a regression test for this bug. |
|
47 |
*/ |
|
48 |
||
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
49 |
import java.util.Arrays; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
50 |
import java.util.List; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
51 |
import java.util.Random; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
52 |
import java.util.concurrent.CyclicBarrier; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
53 |
import java.util.concurrent.atomic.AtomicInteger; |
2 | 54 |
import java.util.logging.LogManager; |
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
55 |
import java.io.File; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
56 |
import java.io.InputStream; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
57 |
import java.io.InputStreamReader; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
58 |
import java.io.Reader; |
2 | 59 |
|
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
60 |
public class LoggingDeadlock2 { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
61 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
62 |
public static void realMain(String arg[]) throws Throwable { |
2 | 63 |
try { |
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
64 |
System.out.println(javaChildArgs); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
65 |
ProcessBuilder pb = new ProcessBuilder(javaChildArgs); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
66 |
ProcessResults r = run(pb.start()); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
67 |
equal(r.exitValue(), 99); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
68 |
equal(r.out(), ""); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
69 |
equal(r.err(), ""); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
70 |
} catch (Throwable t) { unexpected(t); } |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
71 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
72 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
73 |
public static class JavaChild { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
74 |
public static void main(String args[]) throws Throwable { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
75 |
final CyclicBarrier startingGate = new CyclicBarrier(2); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
76 |
final Throwable[] thrown = new Throwable[1]; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
77 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
78 |
// Some random variation, to help tickle races. |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
79 |
final Random rnd = new Random(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
80 |
final boolean dojoin = rnd.nextBoolean(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
81 |
final int JITTER = 1024; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
82 |
final int iters1 = rnd.nextInt(JITTER); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
83 |
final int iters2 = JITTER - iters1; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
84 |
final AtomicInteger counter = new AtomicInteger(0); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
85 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
86 |
Thread exiter = new Thread() { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
87 |
public void run() { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
88 |
try { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
89 |
startingGate.await(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
90 |
for (int i = 0; i < iters1; i++) |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
91 |
counter.getAndIncrement(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
92 |
System.exit(99); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
93 |
} catch (Throwable t) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
94 |
t.printStackTrace(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
95 |
System.exit(86); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
96 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
97 |
}}; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
98 |
exiter.start(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
99 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
100 |
startingGate.await(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
101 |
for (int i = 0; i < iters2; i++) |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
102 |
counter.getAndIncrement(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
103 |
// This may or may not result in a first call to |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
104 |
// Runtime.addShutdownHook after shutdown has already |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
105 |
// commenced. |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
106 |
LogManager log = LogManager.getLogManager(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
107 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
108 |
if (dojoin) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
109 |
exiter.join(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
110 |
if (thrown[0] != null) |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
111 |
throw new Error(thrown[0]); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
112 |
check(counter.get() == JITTER); |
2 | 113 |
} |
114 |
} |
|
115 |
} |
|
116 |
||
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
117 |
//---------------------------------------------------------------- |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
118 |
// The rest of this test is copied from ProcessBuilder/Basic.java |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
119 |
//---------------------------------------------------------------- |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
120 |
private static final String javaExe = |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
121 |
System.getProperty("java.home") + |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
122 |
File.separator + "bin" + File.separator + "java"; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
123 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
124 |
private static final String classpath = |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
125 |
System.getProperty("java.class.path"); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
126 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
127 |
private static final List<String> javaChildArgs = |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
128 |
Arrays.asList(new String[] |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
129 |
{ javaExe, "-classpath", classpath, |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
130 |
"LoggingDeadlock2$JavaChild"}); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
131 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
132 |
private static class ProcessResults { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
133 |
private final String out; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
134 |
private final String err; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
135 |
private final int exitValue; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
136 |
private final Throwable throwable; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
137 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
138 |
public ProcessResults(String out, |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
139 |
String err, |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
140 |
int exitValue, |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
141 |
Throwable throwable) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
142 |
this.out = out; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
143 |
this.err = err; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
144 |
this.exitValue = exitValue; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
145 |
this.throwable = throwable; |
2 | 146 |
} |
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
147 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
148 |
public String out() { return out; } |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
149 |
public String err() { return err; } |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
150 |
public int exitValue() { return exitValue; } |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
151 |
public Throwable throwable() { return throwable; } |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
152 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
153 |
public String toString() { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
154 |
StringBuilder sb = new StringBuilder(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
155 |
sb.append("<STDOUT>\n" + out() + "</STDOUT>\n") |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
156 |
.append("<STDERR>\n" + err() + "</STDERR>\n") |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
157 |
.append("exitValue = " + exitValue + "\n"); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
158 |
if (throwable != null) |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
159 |
sb.append(throwable.getStackTrace()); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
160 |
return sb.toString(); |
2 | 161 |
} |
162 |
} |
|
2631
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
163 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
164 |
private static class StreamAccumulator extends Thread { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
165 |
private final InputStream is; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
166 |
private final StringBuilder sb = new StringBuilder(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
167 |
private Throwable throwable = null; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
168 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
169 |
public String result () throws Throwable { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
170 |
if (throwable != null) |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
171 |
throw throwable; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
172 |
return sb.toString(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
173 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
174 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
175 |
StreamAccumulator (InputStream is) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
176 |
this.is = is; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
177 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
178 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
179 |
public void run() { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
180 |
try { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
181 |
Reader r = new InputStreamReader(is); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
182 |
char[] buf = new char[4096]; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
183 |
int n; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
184 |
while ((n = r.read(buf)) > 0) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
185 |
sb.append(buf,0,n); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
186 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
187 |
} catch (Throwable t) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
188 |
throwable = t; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
189 |
} finally { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
190 |
try { is.close(); } |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
191 |
catch (Throwable t) { throwable = t; } |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
192 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
193 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
194 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
195 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
196 |
private static ProcessResults run(Process p) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
197 |
Throwable throwable = null; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
198 |
int exitValue = -1; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
199 |
String out = ""; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
200 |
String err = ""; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
201 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
202 |
StreamAccumulator outAccumulator = |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
203 |
new StreamAccumulator(p.getInputStream()); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
204 |
StreamAccumulator errAccumulator = |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
205 |
new StreamAccumulator(p.getErrorStream()); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
206 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
207 |
try { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
208 |
outAccumulator.start(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
209 |
errAccumulator.start(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
210 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
211 |
exitValue = p.waitFor(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
212 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
213 |
outAccumulator.join(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
214 |
errAccumulator.join(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
215 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
216 |
out = outAccumulator.result(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
217 |
err = errAccumulator.result(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
218 |
} catch (Throwable t) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
219 |
throwable = t; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
220 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
221 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
222 |
return new ProcessResults(out, err, exitValue, throwable); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
223 |
} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
224 |
|
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
225 |
//--------------------- Infrastructure --------------------------- |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
226 |
static volatile int passed = 0, failed = 0; |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
227 |
static void pass() {passed++;} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
228 |
static void fail() {failed++; Thread.dumpStack();} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
229 |
static void fail(String msg) {System.out.println(msg); fail();} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
230 |
static void unexpected(Throwable t) {failed++; t.printStackTrace();} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
231 |
static void check(boolean cond) {if (cond) pass(); else fail();} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
232 |
static void check(boolean cond, String m) {if (cond) pass(); else fail(m);} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
233 |
static void equal(Object x, Object y) { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
234 |
if (x == null ? y == null : x.equals(y)) pass(); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
235 |
else fail(x + " not equal to " + y);} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
236 |
public static void main(String[] args) throws Throwable { |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
237 |
try {realMain(args);} catch (Throwable t) {unexpected(t);} |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
238 |
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
29398881792c
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents:
2401
diff
changeset
|
239 |
if (failed > 0) throw new AssertionError("Some tests failed");} |
2 | 240 |
} |