commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1211681 - /commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
Date Wed, 07 Dec 2011 22:35:51 GMT
Author: simonetripodi
Date: Wed Dec  7 22:35:51 2011
New Revision: 1211681

URL: http://svn.apache.org/viewvc?rev=1211681&view=rev
Log:
removed synchronizations that caused findbugs issues, the Digester is not anyway thread-safety
by definition so that should not be an issue - unless users start sharing same Digester instances
across multiple threads

Modified:
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java?rev=1211681&r1=1211680&r2=1211681&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
Wed Dec  7 22:35:51 2011
@@ -54,7 +54,6 @@ public class ObjectCreateRule
 
         DeferredConstructionCallback( Constructor<?> constructor, Object[] constructorArgs
)
         {
-            super();
             this.constructor = constructor;
             this.constructorArgs = constructorArgs;
         }
@@ -62,13 +61,10 @@ public class ObjectCreateRule
         public Object intercept( Object obj, Method method, Object[] args, MethodProxy proxy
)
             throws Throwable
         {
-            boolean hasDelegate;
-            synchronized ( this ) {
-                hasDelegate = delegate != null;
-                if ( !hasDelegate )
-                {
-                    invocations.add( new RecordedInvocation( method, args ) );
-                }
+            boolean hasDelegate = delegate != null;
+            if ( !hasDelegate )
+            {
+                invocations.add( new RecordedInvocation( method, args ) );
             }
             if ( hasDelegate ) {
                 return proxy.invoke( delegate, args );
@@ -76,7 +72,7 @@ public class ObjectCreateRule
             return proxy.invokeSuper( obj, args );
         }
 
-        synchronized void establishDelegate()
+        void establishDelegate()
             throws Exception
         {
             convertTo( constructor.getParameterTypes(), constructorArgs );
@@ -147,31 +143,26 @@ public class ObjectCreateRule
             DeferredConstructionCallback callback = new DeferredConstructionCallback(constructor,
constructorArguments);
 
             Object result;
+
             if ( factory == null )
             {
-                synchronized ( this )
+                Enhancer enhancer = new Enhancer();
+                enhancer.setSuperclass( clazz );
+                enhancer.setCallback( callback );
+                enhancer.setClassLoader( digester.getClassLoader() );
+                enhancer.setInterceptDuringConstruction(false);
+                if ( hasDefaultConstructor )
                 {
-                    // check again for null now that we're in the synchronized block:
-                    if ( factory == null )
-                    {
-                        Enhancer enhancer = new Enhancer();
-                        enhancer.setSuperclass( clazz );
-                        enhancer.setCallback( callback );
-                        enhancer.setClassLoader( digester.getClassLoader() );
-                        enhancer.setInterceptDuringConstruction(false);
-                        if ( hasDefaultConstructor )
-                        {
-                            result = enhancer.create();
-                        }
-                        else
-                        {
-                            result = enhancer.create( constructor.getParameterTypes(), constructorArguments
);
-                        }
-                        factory = (Factory) result;
-                        return result;
-                    }
+                    result = enhancer.create();
                 }
+                else
+                {
+                    result = enhancer.create( constructor.getParameterTypes(), constructorArguments
);
+                }
+                factory = (Factory) result;
+                return result;
             }
+
             if ( hasDefaultConstructor )
             {
                 result = factory.newInstance( callback );
@@ -359,22 +350,16 @@ public class ObjectCreateRule
         {
             if ( proxyManager == null )
             {
-                synchronized ( this )
-                {
-                    if ( proxyManager == null )
-                    {
-                        Constructor<?> constructor = getAccessibleConstructor( clazz,
constructorArgumentTypes );
+                Constructor<?> constructor = getAccessibleConstructor( clazz, constructorArgumentTypes
);
 
-                        if ( constructor == null )
-                        {
-                            throw new SAXException( format( "[ObjectCreateRule]{%s} Class
'%s' does not have a construcor with types %s",
-                                                            getDigester().getMatch(),
-                                                            clazz.getName(),
-                                                            Arrays.toString( constructorArgumentTypes
) ) );
-                        }
-                        proxyManager = new ProxyManager(clazz, constructor, defaultConstructorArguments,
getDigester());
-                    }
+                if ( constructor == null )
+                {
+                    throw new SAXException( format( "[ObjectCreateRule]{%s} Class '%s' does
not have a construcor with types %s",
+                                                    getDigester().getMatch(),
+                                                    clazz.getName(),
+                                                    Arrays.toString( constructorArgumentTypes
) ) );
                 }
+                proxyManager = new ProxyManager(clazz, constructor, defaultConstructorArguments,
getDigester());
             }
             instance = proxyManager.createProxy();
         }



Mime
View raw message