You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/01/23 14:46:27 UTC

svn commit: r1726396 - /jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java

Author: pmouawad
Date: Sat Jan 23 13:46:27 2016
New Revision: 1726396

URL: http://svn.apache.org/viewvc?rev=1726396&view=rev
Log:
Bug 58903 - Provide __jexl3 function that uses commons-jexl3 and deprecated __jexl (1.1) function
1/ Switch debug to false to avoid loosing a factory of 6 to 7 degradation
2/ Workaround for performance issue https://issues.apache.org/jira/browse/JEXL-186

Bugzilla Id: 58903

Modified:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java?rev=1726396&r1=1726395&r2=1726396&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/Jexl3Function.java Sat Jan 23 13:46:27 2016
@@ -20,6 +20,7 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.commons.jexl3.JexlArithmetic;
 import org.apache.commons.jexl3.JexlBuilder;
 import org.apache.commons.jexl3.JexlContext;
 import org.apache.commons.jexl3.JexlEngine;
@@ -107,7 +108,31 @@ public class Jexl3Function extends Abstr
         }
         return str;
     }
+    
+    /**
+     * FIXME Remove when upgrading to commons-jexl3-3.1
+     *
+     */
+    private static class JMeterArithmetic extends JexlArithmetic {
+        public JMeterArithmetic(boolean astrict) {
+            super(astrict);
+        }
 
+        /**
+         * A workaround to create an operator overload.
+         *  the 'size' method is discovered through introspection as
+         * an overload of the 'size' operator; this creates an entry in a cache for
+         * that arithmetic class avoiding to re-discover the operator overloads
+         * (Uberspect) on each execution. So, no, this method is not called; it is just
+         * meant as a workaround of the bug.
+         * @see https://issues.apache.org/jira/browse/JEXL-186
+         * @param jma an improbable parameter class
+         * @return 1
+         */
+        public int size(JMeterArithmetic jma) {
+            return 1;
+        }
+    }
     /**
      * Get JexlEngine from ThreadLocal
      * @return JexlEngine
@@ -119,6 +144,12 @@ public class Jexl3Function extends Abstr
                     .cache(512)
                     .silent(true)
                     .strict(true)
+                    // debug is true by default an impact negatively performances
+                    // by a factory of 10
+                    // Use JexlInfo if necessary
+                    .debug(false)
+                    // see https://issues.apache.org/jira/browse/JEXL-186
+                    .arithmetic(new JMeterArithmetic(true))
                     .create();
             threadLocalJexl.set(engine);
         }