You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/10/07 20:40:52 UTC

svn commit: r1180143 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java

Author: hlship
Date: Fri Oct  7 18:40:52 2011
New Revision: 1180143

URL: http://svn.apache.org/viewvc?rev=1180143&view=rev
Log:
TAP5-1650: Apply patch to minimize (but not fully remove) class-loader related deadlocks

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java?rev=1180143&r1=1180142&r2=1180143&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java Fri Oct  7 18:40:52 2011
@@ -82,11 +82,11 @@ public final class ComponentInstantiator
 
     // These change whenever the invalidation event hub sends an invalidation notification
 
-    private ClassFactory classFactory;
+    private volatile ClassFactory classFactory;
 
-    private PlasticProxyFactory proxyFactory;
+    private volatile PlasticProxyFactory proxyFactory;
 
-    private PlasticManager manager;
+    private volatile PlasticManager manager;
 
     /**
      * Map from class name to Instantiator.
@@ -228,33 +228,38 @@ public final class ComponentInstantiator
                 {
                     public Instantiator invoke()
                     {
-                        // Force the creation of the class (and the transformation of the class). This will first
-                        // trigger transformations of any base classes.
+                        ClassLoader proxyClassLoader = proxyFactory.getClassLoader();
 
-                        final ClassInstantiator<Component> plasticInstantiator = manager
-                                .getClassInstantiator(className);
-
-                        final ComponentModel model = classToModel.get(className);
-
-                        return new Instantiator()
+                        synchronized (proxyClassLoader)
                         {
-                            public Component newInstance(InternalComponentResources resources)
-                            {
-                                return plasticInstantiator.with(ComponentResources.class, resources)
-                                        .with(InternalComponentResources.class, resources).newInstance();
-                            }
+                            // Force the creation of the class (and the transformation of the class). This will first
+                            // trigger transformations of any base classes.
 
-                            public ComponentModel getModel()
-                            {
-                                return model;
-                            }
+                            final ClassInstantiator<Component> plasticInstantiator = manager
+                                    .getClassInstantiator(className);
+
+                            final ComponentModel model = classToModel.get(className);
 
-                            @Override
-                            public String toString()
+                            return new Instantiator()
                             {
-                                return String.format("[Instantiator[%s]", className);
-                            }
-                        };
+                                public Component newInstance(InternalComponentResources resources)
+                                {
+                                    return plasticInstantiator.with(ComponentResources.class, resources)
+                                            .with(InternalComponentResources.class, resources).newInstance();
+                                }
+
+                                public ComponentModel getModel()
+                                {
+                                    return model;
+                                }
+
+                                @Override
+                                public String toString()
+                                {
+                                    return String.format("[Instantiator[%s]", className);
+                                }
+                            };
+                        }
                     }
                 });
     }