tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1171321 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImpl.java
Date Thu, 15 Sep 2011 23:11:28 GMT
Author: hlship
Date: Thu Sep 15 23:11:28 2011
New Revision: 1171321

URL: http://svn.apache.org/viewvc?rev=1171321&view=rev
Log:
Revert "TAP5-1650: On a cold start with a large number of incoming requests, Tapestry can
deadlock inside PlasticClassLoader/PlasticClassPool"

This reverts commit cec8f4ae4ddd776729f5a3a684b53b4fbb4dee15.

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=1171321&r1=1171320&r2=1171321&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
Thu Sep 15 23:11:28 2011
@@ -161,7 +161,7 @@ public final class ComponentInstantiator
         hub.addUpdateListener(this);
     }
 
-    public void checkForUpdates()
+    public synchronized void checkForUpdates()
     {
         if (changeTracker.containsChanges())
         {
@@ -171,7 +171,8 @@ public final class ComponentInstantiator
 
     public void objectWasInvalidated()
     {
-        classLoaderLock.lock();
+        changeTracker.clear();
+        classToInstantiator.clear();
 
         // Release the existing class pool, loader and so forth.
         // Create a new one.
@@ -185,55 +186,38 @@ public final class ComponentInstantiator
      */
     private void initializeService()
     {
-        classLoaderLock.lock();
+        PlasticManagerBuilder builder = PlasticManager.withClassLoader(parent).delegate(this)
+                .packages(controlledPackageNames).classLoaderLock(classLoaderLock);
 
-        try
+        if (!productionMode)
         {
+            builder.enable(TransformationOption.FIELD_WRITEBEHIND);
+        }
 
-            PlasticManagerBuilder builder = PlasticManager.withClassLoader(parent).delegate(this)
-                    .packages(controlledPackageNames).classLoaderLock(classLoaderLock);
-
-            if (!productionMode)
-            {
-                builder.enable(TransformationOption.FIELD_WRITEBEHIND);
-            }
-
-            manager = builder.create();
+        manager = builder.create();
 
-            manager.addPlasticClassListener(this);
+        manager.addPlasticClassListener(this);
 
-            classFactory = new ClassFactoryImpl(manager.getClassLoader(), logger);
+        classFactory = new ClassFactoryImpl(manager.getClassLoader(), logger);
 
-            proxyFactory = new PlasticProxyFactoryImpl(manager.getClassLoader(), logger,
classLoaderLock);
+        proxyFactory = new PlasticProxyFactoryImpl(manager.getClassLoader(), logger, classLoaderLock);
 
-            classToInstantiator.clear();
-            classToModel.clear();
-        } finally
-        {
-            classLoaderLock.unlock();
-        }
+        classToInstantiator.clear();
+        classToModel.clear();
     }
 
-    public Instantiator getInstantiator(final String className)
+    public synchronized Instantiator getInstantiator(final String className)
     {
-        classLoaderLock.lock();
+        Instantiator result = classToInstantiator.get(className);
 
-        try
+        if (result == null)
         {
-            Instantiator result = classToInstantiator.get(className);
+            result = createInstantiatorForClass(className);
 
-            if (result == null)
-            {
-                result = createInstantiatorForClass(className);
-
-                classToInstantiator.put(className, result);
-            }
-
-            return result;
-        } finally
-        {
-            classLoaderLock.unlock();
+            classToInstantiator.put(className, result);
         }
+
+        return result;
     }
 
     private Instantiator createInstantiatorForClass(final String className)



Mime
View raw message