You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fs...@apache.org on 2015/02/01 16:38:42 UTC
svn commit: r1656319 -
/tomcat/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
Author: fschumacher
Date: Sun Feb 1 15:38:42 2015
New Revision: 1656319
URL: http://svn.apache.org/r1656319
Log:
Guard the digester with its own lock object. Otherwise two threads could create
two digester instances, lock on them and then use still the same one at the
same time. Remove the now unneeded volatile marker from digester. Issue
reported by Coverity Scan.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java?rev=1656319&r1=1656318&r2=1656319&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java Sun Feb 1 15:38:42 2015
@@ -36,10 +36,11 @@ public class MbeansDescriptorsDigesterSo
{
private static final Log log =
LogFactory.getLog(MbeansDescriptorsDigesterSource.class);
+ private static final Object dLock = new Object();
private Registry registry;
private final List<ObjectName> mbeans = new ArrayList<>();
- private static volatile Digester digester = null;
+ private static Digester digester = null;
private static Digester createDigester() {
@@ -156,12 +157,11 @@ public class MbeansDescriptorsDigesterSo
InputStream stream = (InputStream) source;
- if (digester == null) {
- digester = createDigester();
- }
ArrayList<ManagedBean> loadedMbeans = new ArrayList<>();
-
- synchronized (digester) {
+ synchronized(dLock) {
+ if (digester == null) {
+ digester = createDigester();
+ }
// Process the input file to configure our registry
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org