Author: asoldano
Date: 2013-12-04 19:19:30 -0500 (Wed, 04 Dec 2013)
New Revision: 18135
Modified:
common/trunk/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
common/trunk/src/main/java/org/jboss/ws/common/monitoring/AbstractRecordProcessor.java
common/trunk/src/main/java/org/jboss/ws/common/monitoring/HostFilter.java
common/trunk/src/main/java/org/jboss/ws/common/monitoring/LogRecorder.java
common/trunk/src/main/java/org/jboss/ws/common/monitoring/MemoryBufferRecorder.java
common/trunk/src/main/java/org/jboss/ws/common/monitoring/RecordFactory.java
Log:
Misc concurrency issue prevention from ThreadSafe analysis
Modified:
common/trunk/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java 2013-12-04
21:33:50 UTC (rev 18134)
+++
common/trunk/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java 2013-12-05
00:19:30 UTC (rev 18135)
@@ -23,7 +23,7 @@
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
+import java.util.concurrent.CopyOnWriteArrayList;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -67,7 +67,7 @@
protected LifecycleHandler lifecycleHandler;
protected EndpointMetrics metrics;
protected String address;
- protected List<RecordProcessor> recordProcessors = new
Vector<RecordProcessor>(2);
+ protected List<RecordProcessor> recordProcessors = new
CopyOnWriteArrayList<RecordProcessor>();
protected SecurityDomainContext securityDomainContext;
protected InstanceProvider instanceProvider;
@@ -262,7 +262,7 @@
public void setRecordProcessors(List<RecordProcessor> recordProcessors)
{
- this.recordProcessors = new Vector<RecordProcessor>(recordProcessors);
+ this.recordProcessors = new
CopyOnWriteArrayList<RecordProcessor>(recordProcessors);
}
public void processRecord(Record record)
Modified:
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2013-12-04
21:33:50 UTC (rev 18134)
+++
common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2013-12-05
00:19:30 UTC (rev 18135)
@@ -88,7 +88,7 @@
private final Object modifySOAPAddressLock = new Object();
//The stack config
- protected StackConfig stackConfig;
+ protected volatile StackConfig stackConfig;
// The default endpoint configs, if any
private final List<ClientConfig> clientConfigs = new
CopyOnWriteArrayList<ClientConfig>();
// The default endpoint configs, if any
Modified:
common/trunk/src/main/java/org/jboss/ws/common/monitoring/AbstractRecordProcessor.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/monitoring/AbstractRecordProcessor.java 2013-12-04
21:33:50 UTC (rev 18134)
+++
common/trunk/src/main/java/org/jboss/ws/common/monitoring/AbstractRecordProcessor.java 2013-12-05
00:19:30 UTC (rev 18135)
@@ -22,7 +22,7 @@
package org.jboss.ws.common.monitoring;
import java.util.List;
-import java.util.Vector;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.ws.api.monitoring.Record;
import org.jboss.ws.api.monitoring.RecordFilter;
@@ -37,7 +37,9 @@
*/
public abstract class AbstractRecordProcessor implements RecordProcessor
{
- protected List<RecordFilter> filters = new Vector<RecordFilter>(1);
+ private static final long serialVersionUID = -1825185742740851152L;
+
+ protected List<RecordFilter> filters = new
CopyOnWriteArrayList<RecordFilter>();
protected boolean processDestinationHost = true;
protected boolean processSourceHost = true;
protected boolean processHeaders = true;
@@ -72,7 +74,7 @@
public void setFilters(List<RecordFilter> filters)
{
- this.filters = new Vector<RecordFilter>(filters);
+ this.filters = new CopyOnWriteArrayList<RecordFilter>(filters);
}
public boolean isProcessDestinationHost()
@@ -159,7 +161,7 @@
public Object clone() throws CloneNotSupportedException
{
AbstractRecordProcessor retObj = (AbstractRecordProcessor)super.clone();
- retObj.filters = new Vector<RecordFilter>();
+ retObj.filters = new CopyOnWriteArrayList<RecordFilter>();
for (RecordFilter fil : this.filters)
{
RecordFilter clFil = (RecordFilter)fil.clone();
Modified: common/trunk/src/main/java/org/jboss/ws/common/monitoring/HostFilter.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/monitoring/HostFilter.java 2013-12-04
21:33:50 UTC (rev 18134)
+++ common/trunk/src/main/java/org/jboss/ws/common/monitoring/HostFilter.java 2013-12-05
00:19:30 UTC (rev 18135)
@@ -22,6 +22,7 @@
package org.jboss.ws.common.monitoring;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -39,17 +40,23 @@
{
private static final long serialVersionUID = -5935962601380315102L;
- private List<String> hosts = new LinkedList<String>();
- private boolean source;
+ private final List<String> hosts;
+ private final boolean source;
public HostFilter(String host, boolean source)
{
- this.hosts.add(host);
+ this.hosts = Collections.singletonList(host);
this.source = source;
}
public HostFilter(Collection<String> hosts, boolean source)
{
+ if (hosts instanceof List) {
+ this.hosts = Collections.unmodifiableList((List<String>)hosts);
+ } else {
+ final List<String> l = new LinkedList<String>(hosts);
+ this.hosts = Collections.unmodifiableList(l);
+ }
this.hosts.addAll(hosts);
this.source = source;
}
@@ -79,9 +86,6 @@
@Override
public Object clone() throws CloneNotSupportedException
{
- HostFilter retObj = (HostFilter)super.clone();
- retObj.hosts = new LinkedList<String>(this.hosts);
- retObj.source = this.source;
- return retObj;
+ return new HostFilter(this.hosts, this.source);
}
}
Modified: common/trunk/src/main/java/org/jboss/ws/common/monitoring/LogRecorder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/monitoring/LogRecorder.java 2013-12-04
21:33:50 UTC (rev 18134)
+++ common/trunk/src/main/java/org/jboss/ws/common/monitoring/LogRecorder.java 2013-12-05
00:19:30 UTC (rev 18135)
@@ -48,6 +48,9 @@
@Override
public void processRecord(Record record)
{
+ if (!Loggers.MONITORING_LOGGER.isDebugEnabled()) {
+ return;
+ }
StringBuilder sb = new StringBuilder();
if (this.isProcessMessageType())
{
Modified:
common/trunk/src/main/java/org/jboss/ws/common/monitoring/MemoryBufferRecorder.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/monitoring/MemoryBufferRecorder.java 2013-12-04
21:33:50 UTC (rev 18134)
+++
common/trunk/src/main/java/org/jboss/ws/common/monitoring/MemoryBufferRecorder.java 2013-12-05
00:19:30 UTC (rev 18135)
@@ -51,7 +51,7 @@
private Map<String, List<Record>> recentRecords =
Collections.synchronizedMap(new HashMap<String, List<Record>>());
private ConcurrentLinkedQueue<String> recentRecordGroups = new
ConcurrentLinkedQueue<String>();
- private int size = 0;
+ private volatile int size = 0;
private volatile int maxSize = 50;
public MemoryBufferRecorder()
@@ -273,20 +273,23 @@
{
MemoryBufferRecorder cl = (MemoryBufferRecorder)super.clone();
cl.recentRecords = Collections.synchronizedMap(new HashMap<String,
List<Record>>());
- for (String key : this.recentRecords.keySet())
+ synchronized (this.recentRecords)
{
- List<Record> list = new LinkedList<Record>();
- for (Record record : this.recentRecords.get(key))
+ for (String key : this.recentRecords.keySet())
{
- list.add(record);
+ List<Record> list = new LinkedList<Record>();
+ for (Record record : this.recentRecords.get(key))
+ {
+ list.add(record);
+ }
+ cl.recentRecords.put(key, list);
}
- cl.recentRecords.put(key, list);
+ cl.recentRecordGroups = new ConcurrentLinkedQueue<String>();
+ for (String id : this.recentRecordGroups)
+ {
+ cl.recentRecordGroups.add(id);
+ }
}
- cl.recentRecordGroups = new ConcurrentLinkedQueue<String>();
- for (String id : this.recentRecordGroups)
- {
- cl.recentRecordGroups.add(id);
- }
cl.maxSize = this.maxSize;
cl.size = this.size;
return cl;
Modified: common/trunk/src/main/java/org/jboss/ws/common/monitoring/RecordFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/ws/common/monitoring/RecordFactory.java 2013-12-04
21:33:50 UTC (rev 18134)
+++
common/trunk/src/main/java/org/jboss/ws/common/monitoring/RecordFactory.java 2013-12-05
00:19:30 UTC (rev 18135)
@@ -40,8 +40,8 @@
synchronized (RecordFactory.class)
{
count++;
+ sb.append(count);
}
- sb.append(count);
sb.append("-");
sb.append(time);
return sb.toString();
Show replies by date