You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2012/01/22 22:31:02 UTC
svn commit: r1234617 -
/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
Author: oheger
Date: Sun Jan 22 21:31:01 2012
New Revision: 1234617
URL: http://svn.apache.org/viewvc?rev=1234617&view=rev
Log:
Fixed an issue reported by FindBugs: CopyOnWriteArrayList was used in synchronized() block.
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java?rev=1234617&r1=1234616&r2=1234617&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java Sun Jan 22 21:31:01 2012
@@ -75,6 +75,9 @@ public class EventSource
/** A collection for the registered error listeners.*/
private Collection<ConfigurationErrorListener> errorListeners;
+ /** A lock object for guarding access to the detail events counter. */
+ private final Object lockDetailEventsCount = new Object();
+
/** A counter for the detail events. */
private int detailEvents;
@@ -152,7 +155,7 @@ public class EventSource
*/
public void setDetailEvents(boolean enable)
{
- synchronized (listeners)
+ synchronized (lockDetailEventsCount)
{
if (enable)
{
@@ -353,7 +356,7 @@ public class EventSource
*/
private boolean checkDetailEvents(int limit)
{
- synchronized (listeners)
+ synchronized (lockDetailEventsCount)
{
return detailEvents > limit;
}