mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (4.3/Cloud)
73356: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 73285: Merged DEV to V4.2-BUG-FIX (4.2.3) 73210: MNT-11640 : Intermittent test failure: NPE in DynamicallySizedThreadPoolExecutorTest testToExpandQueue Hardened the test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@74774 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
@@ -304,7 +306,7 @@ public class DynamicallySizedThreadPoolExecutorTest extends TestCase
|
||||
|
||||
public static class SleepUntilAllWake implements Runnable
|
||||
{
|
||||
private static ArrayList<Thread> sleeping = new ArrayList<Thread>();
|
||||
private static ConcurrentMap<String, Thread> sleeping = new ConcurrentHashMap<String, Thread>();
|
||||
private static boolean allAwake = false;
|
||||
|
||||
@Override
|
||||
@@ -313,23 +315,31 @@ public class DynamicallySizedThreadPoolExecutorTest extends TestCase
|
||||
if(allAwake) return;
|
||||
|
||||
// Track us, and wait for the bang
|
||||
sleeping.add(Thread.currentThread());
|
||||
logger.debug("Adding thread: " + Thread.currentThread().getName());
|
||||
sleeping.put(Thread.currentThread().getName(), Thread.currentThread());
|
||||
try
|
||||
{
|
||||
Thread.sleep(30*1000);
|
||||
System.err.println("Warning - Thread finished sleeping without wake!");
|
||||
} catch(InterruptedException e) {}
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
logger.debug("Interrupted thread: " + Thread.currentThread().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void wakeAll()
|
||||
{
|
||||
allAwake = true;
|
||||
for(Thread t : sleeping) {
|
||||
t.interrupt();
|
||||
for(Entry<String, Thread> t : sleeping.entrySet())
|
||||
{
|
||||
logger.debug("Interrupting thread: " + t.getKey());
|
||||
t.getValue().interrupt();
|
||||
}
|
||||
}
|
||||
public static void reset()
|
||||
{
|
||||
logger.debug("Resetting.");
|
||||
allAwake = false;
|
||||
sleeping.clear();
|
||||
}
|
||||
|
Reference in New Issue
Block a user