8255277: randomDelay in DrainDeadlockT and LoggingDeadlock do not randomly delay
Reviewed-by: lancea
This commit is contained in:
parent
2d30a10138
commit
a93841ac9c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,9 +25,11 @@ import java.lang.management.ThreadMXBean;
|
||||
import java.lang.Thread.State;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Random;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.Map;
|
||||
import jdk.test.lib.RandomFactory;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -36,6 +38,7 @@ import java.util.Map;
|
||||
* @author jim.gish@oracle.com
|
||||
* @modules java.logging
|
||||
* java.management
|
||||
* @library /test/lib
|
||||
* @build DrainFindDeadlockTest
|
||||
* @run main/othervm DrainFindDeadlockTest
|
||||
* @key randomness
|
||||
@ -50,6 +53,8 @@ import java.util.Map;
|
||||
public class DrainFindDeadlockTest {
|
||||
private LogManager mgr = LogManager.getLogManager();
|
||||
private static final int MAX_ITERATIONS = 100;
|
||||
private static final Random random = RandomFactory.getRandom();
|
||||
private static int preventLoopElision;
|
||||
|
||||
// Get a ThreadMXBean so we can check for deadlock. N.B. this may
|
||||
// not be supported on all platforms, which means we will have to
|
||||
@ -66,12 +71,13 @@ public class DrainFindDeadlockTest {
|
||||
}
|
||||
|
||||
public static void randomDelay() {
|
||||
int runs = (int) Math.random() * 1000000;
|
||||
int runs = random.nextInt(1000000);
|
||||
int c = 0;
|
||||
|
||||
for (int i=0; i<runs; ++i) {
|
||||
c=c+i;
|
||||
}
|
||||
preventLoopElision = c;
|
||||
}
|
||||
|
||||
public void testForDeadlock() throws IOException, Exception {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,6 +28,7 @@
|
||||
* @summary deadlock in LogManager
|
||||
* @author Serguei Spitsyn / SAP
|
||||
*
|
||||
* @library /test/lib
|
||||
* @build LoggingDeadlock
|
||||
* @run main/timeout=15 LoggingDeadlock
|
||||
* @key randomness
|
||||
@ -53,18 +54,24 @@
|
||||
*/
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
import jdk.test.lib.RandomFactory;
|
||||
|
||||
public class LoggingDeadlock {
|
||||
|
||||
private static int preventLoopElision;
|
||||
private static final Random random = RandomFactory.getRandom();
|
||||
|
||||
public static void randomDelay() {
|
||||
int runs = (int) Math.random() * 1000000;
|
||||
int runs = random.nextInt(1000000);
|
||||
int c = 0;
|
||||
|
||||
for (int i = 0; i < runs; ++i) {
|
||||
c = c + i;
|
||||
}
|
||||
preventLoopElision = c;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException{
|
||||
|
Loading…
Reference in New Issue
Block a user