Author: hlship
Date: Fri Aug  8 14:25:08 2008
New Revision: 684101

URL: http://svn.apache.org/viewvc?rev=684101&view=rev
Log:
TAPESTRY-2561: Rapidly refreshing a page, even the same page, can cause a 
deadlock related to class loading

Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.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=684101&r1=684100&r2=684101&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 Aug  8 14:25:08 2008
@@ -90,10 +90,10 @@
                 // TAPESTRY-2561: Prevent other threads from creating new 
classes in either
                 // the component class loader or in the context class loader 
(which is used for
                 // IoC proxies and the like). This is draconian, but the 
deadlock issue remains.                
-                synchronized (InternalConstants.GLOBAL_CLASS_CREATION_MUTEX)
-                {
-                    return super.findClass(className);
-                }
+                //  synchronized 
(InternalConstants.GLOBAL_CLASS_CREATION_MUTEX)
+                // {
+                return super.findClass(className);
+                // }
             }
 
             // Returning null forces delegation to the parent class loader.
@@ -179,17 +179,20 @@
 
         try
         {
-            CtClass ctClass = pool.get(classname);
+            synchronized (InternalConstants.GLOBAL_CLASS_CREATION_MUTEX)
+            {
+                CtClass ctClass = pool.get(classname);
 
-            // Force the creation of the super-class before the target class.
+                // Force the creation of the super-class before the target 
class.
 
-            forceSuperclassTransform(ctClass);
+                forceSuperclassTransform(ctClass);
 
-            // Do the transformations here
+                // Do the transformations here
 
-            transformer.transformComponentClass(ctClass, loader);
+                transformer.transformComponentClass(ctClass, loader);
 
-            writeClassToFileSystemForHardCoreDebuggingPurposesOnly(ctClass);
+                
writeClassToFileSystemForHardCoreDebuggingPurposesOnly(ctClass);
+            }
 
             diag = "END";
         }

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java?rev=684101&r1=684100&r2=684101&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
 Fri Aug  8 14:25:08 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
+import org.apache.tapestry5.ioc.internal.InternalConstants;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
 import org.apache.tapestry5.ioc.services.PropertyAccess;
@@ -74,22 +75,25 @@
      * serializes access to the Java Beans Introspector, which is not thread 
safe. In addition, handles the case where
      * the class in question is an interface, accumulating properties 
inherited from super-classes.
      */
-    private synchronized ClassPropertyAdapter buildAdapter(Class forClass)
+    private ClassPropertyAdapter buildAdapter(Class forClass)
     {
         // In some race conditions, we may hit this method for the same class 
multiple times.
         // We just let it happen, replacing the old ClassPropertyAdapter with 
a new one.
 
         try
         {
-            BeanInfo info = Introspector.getBeanInfo(forClass);
+            synchronized (InternalConstants.GLOBAL_CLASS_CREATION_MUTEX)
+            {
+                BeanInfo info = Introspector.getBeanInfo(forClass);
 
-            List<PropertyDescriptor> descriptors = CollectionFactory.newList();
+                List<PropertyDescriptor> descriptors = 
CollectionFactory.newList();
 
-            addAll(descriptors, info.getPropertyDescriptors());
+                addAll(descriptors, info.getPropertyDescriptors());
 
-            if (forClass.isInterface()) 
addPropertiesFromExtendedInterfaces(forClass, descriptors);
+                if (forClass.isInterface()) 
addPropertiesFromExtendedInterfaces(forClass, descriptors);
 
-            return new ClassPropertyAdapterImpl(forClass, descriptors);
+                return new ClassPropertyAdapterImpl(forClass, descriptors);
+            }
         }
         catch (Throwable ex)
         {


Reply via email to