From d222583a4c71585b8c207e0f59441400c6ef37b4 Mon Sep 17 00:00:00 2001
From: davidely <davidely@localhost>
Date: Tue, 20 Feb 2007 12:49:29 +0000
Subject: [PATCH] Fixed ConcurrentModificationException in the unit test infrastructure that we saw with one build. I've also added the enhancement to print the output of System.out and System.err to the command line and unit test report file for any test that fails. I've updated the test docs on the web to reflect this.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/TestErrorLogger.java | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestErrorLogger.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestErrorLogger.java
index 51a2e2b..8a01e65 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestErrorLogger.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestErrorLogger.java
@@ -31,6 +31,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Iterator;
+import java.util.ArrayList;
import org.opends.server.api.ErrorLogger;
import org.opends.server.config.ConfigEntry;
@@ -38,7 +39,6 @@
import org.opends.server.types.ErrorLogSeverity;
-
/**
* This class provides an implementation of an error logger which will store all
* messages logged in memory. It provides methods to retrieve and clear the
@@ -86,16 +86,18 @@
/**
- * Retrieves the set of messages logged to this error logger since the last
- * time it was cleared. The caller must not attempt to alter the list in any
- * way.
+ * Retrieves a copy of the set of messages logged to this error logger since
+ * the last time it was cleared. A copy of the list is returned to avoid
+ * a ConcurrentModificationException.
*
* @return The set of messages logged to this error logger since the last
* time it was cleared.
*/
public static List<String> getMessages()
{
- return SINGLETON.messageList;
+ synchronized (SINGLETON) {
+ return new ArrayList<String>(SINGLETON.messageList);
+ }
}
@@ -105,10 +107,13 @@
*/
public static void clear()
{
- SINGLETON.messageList.clear();
+ synchronized (SINGLETON) {
+ SINGLETON.messageList.clear();
+ }
}
+
/**
* {@inheritDoc}
*/
--
Gitblit v1.10.0