jdk/test/java/util/logging/LoggingDeadlock2.java
author dfuchs
Thu, 06 Aug 2015 16:36:47 +0200
changeset 32035 073a449c007d
parent 31534 28d66c729c18
child 44640 590dec7cadb4
permissions -rw-r--r--
8132550: java/util/logging/LoggingDeadlock2.java times out Summary: LogManager must also use the configurationLock when reading its primordial configuration. Reviewed-by: joehw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14856
92a1bcf46888 8004982: JDK8 source with GPL header errors
katleman
parents: 14683
diff changeset
     2
 * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2930
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2930
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2930
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
32035
073a449c007d 8132550: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 31534
diff changeset
    26
 * @bug     6467152 6716076 6829503 8132550
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @build    LoggingDeadlock2
25399
a8ec88e2d76f 8048913: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 14856
diff changeset
    31
 * @run  main LoggingDeadlock2
30046
cf2c86e1819e 8078334: Mark regression tests using randomness
darcy
parents: 25399
diff changeset
    32
 * @key randomness
cf2c86e1819e 8078334: Mark regression tests using randomness
darcy
parents: 25399
diff changeset
    33
 */
cf2c86e1819e 8078334: Mark regression tests using randomness
darcy
parents: 25399
diff changeset
    34
cf2c86e1819e 8078334: Mark regression tests using randomness
darcy
parents: 25399
diff changeset
    35
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * There is a clear deadlock between LogManager.<clinit> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Cleaner.run() methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * T1 thread:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *   The LogManager.<clinit> creates LogManager.manager object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *   sets shutdown hook with the Cleaner class and then waits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *   to lock the LogManager.manager monitor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * T2 thread:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *   It is started by the System.exit() as shutdown hook thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *   It locks the LogManager.manager monitor and then calls the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *   static methods of the LogManager class (in this particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *   case it is a trick of the inner classes implementation).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *   It is waits when the LogManager.<clinit> is completed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * This is a regression test for this bug.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
2631
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.Arrays;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    54
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
    55
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
    56
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
    57
import java.util.concurrent.atomic.AtomicInteger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
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
    59
import java.io.File;
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    60
import java.io.IOException;
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    61
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
    62
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
    63
import java.io.Reader;
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    64
import java.util.concurrent.TimeUnit;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    66
public class LoggingDeadlock2 {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    67
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    68
    // ask child process to dumpstack after 60secs
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    69
    public static final long DUMP_STACK_FREQUENCY_MS = 60000;
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    70
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    71
    // A marker that allows to validate the subprocess output.
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    72
    public static final String MARKER = "$";
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    73
2631
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 realMain(String arg[]) throws Throwable {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        try {
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    76
            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
    77
            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
    78
            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
    79
            equal(r.exitValue(), 99);
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    80
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    81
            // output of subprocess should end with "$"
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    82
            final String out = r.out();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    83
            final String trailingOutput = out.indexOf(MARKER) > -1
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    84
                    ? out.substring(out.indexOf(MARKER)+MARKER.length())
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    85
                    : out;
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    86
            equal(trailingOutput, "");
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    87
            equal(r.err(), "");
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    88
            equal(out.startsWith("JavaChild started"), true);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    89
            equal(out.endsWith("$"), true);
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    90
        } 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
    91
    }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    92
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    93
    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
    94
        public static void main(String args[]) throws Throwable {
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    95
            System.out.println("JavaChild started");
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
    96
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
    97
            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
    98
            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
    99
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   100
            // 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
   101
            final Random rnd = new Random();
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   102
            final long seed = rnd.nextLong();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   103
            rnd.setSeed(seed);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   104
            System.out.println("seed=" + seed);
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   105
            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
   106
            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
   107
            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
   108
            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
   109
            final AtomicInteger counter = new AtomicInteger(0);
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   110
            System.out.println("dojoin=" + dojoin);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   111
            System.out.println("iters1=" + iters1);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   112
            System.out.println("iters2=" + iters2);
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   113
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   114
            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
   115
                public void run() {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   116
                    try {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   117
                        startingGate.await();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   118
                        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
   119
                            counter.getAndIncrement();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   120
                        System.exit(99);
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   121
                    } catch (Throwable t) {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   122
                        t.printStackTrace();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   123
                        System.exit(86);
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   124
                    }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   125
                }};
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   126
            exiter.start();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   127
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   128
            System.out.println("exiter started");
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   129
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   130
            // signal end of verbose output
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   131
            System.out.print(MARKER);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   132
            System.out.flush();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   133
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   134
            startingGate.await();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   135
            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
   136
                counter.getAndIncrement();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   137
            // 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
   138
            // 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
   139
            // commenced.
14683
38921a46c62d 8003380: Compiler warnings in logging test code
jgish
parents: 5506
diff changeset
   140
            LogManager.getLogManager();
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   141
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   142
            if (dojoin) {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   143
                exiter.join();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   144
                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
   145
                    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
   146
                check(counter.get() == JITTER);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   151
    //----------------------------------------------------------------
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   152
    // 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
   153
    //----------------------------------------------------------------
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   154
    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
   155
        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
   156
        File.separator + "bin" + File.separator + "java";
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   157
    private static final String jstackExe =
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   158
        System.getProperty("java.home") +
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   159
        File.separator + "bin" + File.separator + "jstack";
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   160
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   161
    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
   162
        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
   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 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
   165
        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
   166
            { javaExe, "-classpath", classpath,
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   167
              "LoggingDeadlock2$JavaChild"});
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
    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
   170
        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
   171
        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
   172
        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
   173
        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
   174
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   175
        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
   176
                              String err,
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   177
                              int exitValue,
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   178
                              Throwable throwable) {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   179
            this.out = out;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   180
            this.err = err;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   181
            this.exitValue = exitValue;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   182
            this.throwable = throwable;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   184
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   185
        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
   186
        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
   187
        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
   188
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   189
        public String toString() {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   190
            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
   191
            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
   192
                .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
   193
                .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
   194
            if (throwable != null)
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   195
                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
   196
            return sb.toString();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   199
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   200
    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
   201
        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
   202
        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
   203
        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
   204
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   205
        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
   206
            if (throwable != null)
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   207
                throw throwable;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   208
            return sb.toString();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   209
        }
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
        StreamAccumulator (InputStream is) {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   212
            this.is = is;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   213
        }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   214
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   215
        public void run() {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   216
            try {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   217
                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
   218
                int n;
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   219
                while ((n = r.read()) > 0) {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   220
                    sb.append((char)n);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   221
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   222
                    // prints everything immediately to System.out so that we can
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   223
                    // see the traces even in the event of a test timeout
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   224
                    System.out.write((char)n);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   225
                    System.out.flush();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   226
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   227
                }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   228
            } catch (Throwable t) {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   229
                throwable = t;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   230
            } finally {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   231
                try { is.close(); }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   232
                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
   233
            }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   234
        }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   235
    }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   236
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   237
    /**
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   238
     * If the child process deadlocks, then the parent may fail in timeout.
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   239
     * In that case, we won't have any interesting traces, unless we manage
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   240
     * to get a thread dump from the child.
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   241
     * It is unsure whether obtaining a thread dump from a deadlocked child
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   242
     * will work - but maybe we could see something if the timeout is a false
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   243
     * positive (the child has not deadlocked but hasn't managed to fully start
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   244
     * yet, for instance).
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   245
     * The idea here is to periodically try to obtain a thread dump from the
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   246
     * child, every 60sec - which should be always less than the jtreg timeout.
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   247
     */
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   248
    private static class TimeoutThread extends Thread {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   249
        final long ms;
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   250
        final Process process;
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   251
        TimeoutThread(long ms, Process p) {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   252
            super("TimeoutThread");
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   253
            setDaemon(true);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   254
            this.ms = ms;
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   255
            this.process = p;
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   256
        }
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   257
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   258
        @Override
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   259
        public void run() {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   260
            long start = System.nanoTime();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   261
            try {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   262
                while (true) {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   263
                    sleep(ms);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   264
                    System.err.println("Timeout reached: " + ms);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   265
                    if (process.isAlive()) {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   266
                        long pid = process.getPid();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   267
                        ProcessBuilder jstack = new ProcessBuilder(jstackExe, String.valueOf(pid));
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   268
                        System.err.println("Dumping subprocess stack: " + pid);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   269
                        Process p = jstack.inheritIO().start();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   270
                        p.waitFor(ms, TimeUnit.MILLISECONDS);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   271
                    } else {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   272
                        System.err.println("Process is not alive!");
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   273
                        break;
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   274
                    }
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   275
                }
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   276
            } catch (InterruptedException ex) {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   277
                System.err.println("Interrupted: " + ex);
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   278
            } catch (IOException io) {
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   279
                System.err.println("Failed to get stack from subprocess");
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   280
                io.printStackTrace();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   281
            }
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   282
        }
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   283
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   284
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   285
    }
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   286
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   287
    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
   288
        Throwable throwable = null;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   289
        int exitValue = -1;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   290
        String out = "";
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   291
        String err = "";
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   292
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   293
        StreamAccumulator outAccumulator =
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   294
            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
   295
        StreamAccumulator errAccumulator =
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   296
            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
   297
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   298
        try {
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   299
            System.out.println("Waiting for child process to exit");
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   300
            outAccumulator.start();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   301
            errAccumulator.start();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   302
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   303
            // ask subprocess to dump stack every 60 secs.
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   304
            new TimeoutThread(DUMP_STACK_FREQUENCY_MS, p).start();
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   305
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   306
            exitValue = p.waitFor();
31534
28d66c729c18 8130649: java/util/logging/LoggingDeadlock2.java times out
dfuchs
parents: 30046
diff changeset
   307
            System.out.println("\nChild exited with status: " + exitValue);
2631
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   308
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   309
            outAccumulator.join();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   310
            errAccumulator.join();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   311
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   312
            out = outAccumulator.result();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   313
            err = errAccumulator.result();
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   314
        } catch (Throwable t) {
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   315
            throwable = t;
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   316
        }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   317
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   318
        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
   319
    }
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   320
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   321
    //--------------------- Infrastructure ---------------------------
29398881792c 6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
martin
parents: 2401
diff changeset
   322
    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
   323
    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
   324
    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
   325
    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
   326
    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
   327
    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
   328
    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
   329
    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
   330
        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
   331
        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
   332
    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
   333
        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
   334
        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
   335
        if (failed > 0) throw new AssertionError("Some tests failed");}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
}