From a5131f44a6afa554af8f4c82c7ffd3d4ceac1bd4 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 04 Feb 2011 12:50:58 +0000
Subject: [PATCH] OPEN - issue OPENDJ-26: Fix OpenDS issue 4585: ConcurrentModificationException in ReplicationBroker https://bugster.forgerock.org/jira/browse/OPENDJ-26
---
opends/src/server/org/opends/server/replication/server/MonitoringPublisher.java | 38 ++++++++++++++++++++++----------------
1 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/MonitoringPublisher.java b/opends/src/server/org/opends/server/replication/server/MonitoringPublisher.java
index d74a43c..862ec67 100644
--- a/opends/src/server/org/opends/server/replication/server/MonitoringPublisher.java
+++ b/opends/src/server/org/opends/server/replication/server/MonitoringPublisher.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
+ * Portions Copyright 2011 ForgeRock AS
*/
package org.opends.server.replication.server;
@@ -52,22 +53,23 @@
public class MonitoringPublisher extends DirectoryThread
{
- private boolean shutdown = false;
+ private volatile boolean shutdown = false;
+
/**
* The tracer object for the debug logger.
*/
private static final DebugTracer TRACER = getTracer();
// The domain we send monitoring for
- private ReplicationServerDomain replicationServerDomain;
+ private final ReplicationServerDomain replicationServerDomain;
// Sleep time (in ms) before sending new monitoring messages.
- private long period = 3000;
+ private volatile long period;
// Is the thread terminated ?
- private boolean done = false;
+ private volatile boolean done = false;
- private final Object sleeper = new Object();
+ private final Object shutdownLock = new Object();
/**
* Create a monitoring publisher.
@@ -104,9 +106,12 @@
{
try
{
- synchronized (sleeper)
+ synchronized (shutdownLock)
{
- sleeper.wait(period);
+ if (!shutdown)
+ {
+ shutdownLock.wait(period);
+ }
}
} catch (InterruptedException ex)
{
@@ -157,16 +162,17 @@
*/
public void shutdown()
{
- if (debugEnabled())
+ synchronized (shutdownLock)
{
- TRACER.debugInfo("Shutting down monitoring publisher for dn " +
- replicationServerDomain.getBaseDn().toString() + " in RS " +
- replicationServerDomain.getReplicationServer().getServerId());
- }
- shutdown = true;
- synchronized (sleeper)
- {
- sleeper.notify();
+ shutdown = true;
+ shutdownLock.notifyAll();
+
+ if (debugEnabled())
+ {
+ TRACER.debugInfo("Shutting down monitoring publisher for dn " +
+ replicationServerDomain.getBaseDn().toString() + " in RS " +
+ replicationServerDomain.getReplicationServer().getServerId());
+ }
}
}
--
Gitblit v1.10.0