Bug 28282 - Performance problems with ExpressionEvaluatorManager
Summary: Performance problems with ExpressionEvaluatorManager
Status: RESOLVED DUPLICATE of bug 25967
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.0
Hardware: All All
: P3 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-08 14:05 UTC by Richard Kraft
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
Remove synchronized from the getEvaluatorByName method (1.61 KB, patch)
2004-04-08 14:06 UTC, Richard Kraft
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Kraft 2004-04-08 14:05:48 UTC
ExpressionEvaluatorManager has a synchronized method that causes every use of
evaluate to block.  This causes major issues when the taglibs are used in a high
throughput environment.


I have patched the code as indicated below:

--- ExpressionEvaluatorManager.java.orig	2004-04-08 03:42:02.000000000 -0500
+++ ExpressionEvaluatorManager.java	2004-04-08 08:58:40.302582400 -0500
@@ -99,20 +99,22 @@
      * Gets an ExpressionEvaluator from the cache, or seeds the cache
      * if we haven't seen a particular ExpressionEvaluator before.
      */
-    public static synchronized
-	    ExpressionEvaluator getEvaluatorByName(String name)
-            throws JspException {
+    public static ExpressionEvaluator getEvaluatorByName(String name) throws
JspException
+    {
+        Object oEvaluator = nameMap.get(name);
+        if (oEvaluator != null)
+            return ((ExpressionEvaluator) oEvaluator);
         try {
-
-            Object oEvaluator = nameMap.get(name);
-            if (oEvaluator == null) {
-                ExpressionEvaluator e = (ExpressionEvaluator)
-                    Class.forName(name).newInstance();
-                nameMap.put(name, e);
-                return (e);
-            } else
+                synchronized (nameMap)
+                {
+                    oEvaluator = nameMap.get(name);
+                    if (oEvaluator != null)
+                        return ((ExpressionEvaluator) oEvaluator);
+                    ExpressionEvaluator e = (ExpressionEvaluator)
Class.forName(name).newInstance();
+                    nameMap.put(name, e);
+                    oEvaluator = e;
+                }
                 return ((ExpressionEvaluator) oEvaluator);
-
         } catch (ClassCastException ex) {
             // just to display a better error message
             throw new JspException("invalid ExpressionEvaluator: " +
Comment 1 Richard Kraft 2004-04-08 14:06:59 UTC
Created attachment 11184 [details]
Remove synchronized from the getEvaluatorByName method
Comment 2 Richard Kraft 2004-04-08 16:37:49 UTC

*** This bug has been marked as a duplicate of 25967 ***