You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Marcel Schoen (JIRA)" <ji...@apache.org> on 2010/03/24 11:26:27 UTC

[jira] Created: (JEXL-99) Documentation of Thread Safety / Invalid code examples on homepage

Documentation of Thread Safety / Invalid code examples on homepage
------------------------------------------------------------------

                 Key: JEXL-99
                 URL: https://issues.apache.org/jira/browse/JEXL-99
             Project: Commons JEXL
          Issue Type: Task
    Affects Versions: 2.0
            Reporter: Marcel Schoen
            Priority: Minor


I had trouble with a custom method invoked in a JEXL script. This method throws a RuntimeException, which got swallowed with JEXL 2. Using the debugger, I found the "strict" flag of the Interpreter to be false, even though I had invoked "JexlEngine.setLenient(false)" in my initialization code.

Now I suspect my initialization logic to be faulty, but while I looked into this, I realized that the javadoc of JexlEngine doesn't really tell me if I can use it as a singleton or not (or if I should, for that matter). If so, are its various methods thread-safe or not? It only says so for a few methods like "setDebug()".

In addition, some code examples on the homepage are heavily outdated. For example, the first code fragment on this page

http://commons.apache.org/jexl/reference/examples.html

shows the usage of a class "ExpressionFactory" which doesn't even exist in the JEXL 2 source tree. Of course it would be nice if these examples would show how to correctly use "JexlEngine", for instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JEXL-99) Documentation of Thread Safety / Invalid code examples on homepage

Posted by "Henri Biestro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JEXL-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12849191#action_12849191 ] 

Henri Biestro commented on JEXL-99:
-----------------------------------

Thank you for pointing out the obsolete example; I'll update those momentarily. Till then, the test sources might be better examples.

Regarding thread-safety; a JEXL instance can be used as a singleton - they way it used to be in JEXL 1.x -, its exposed methods are thread-safe (besides when stating they are not) and common usage is to use one shared JexlEngine instance.
Btw, setting a cache - JexlEngine.setCache(...) - during the engine initialization is also usually a good practice.

A typical initialization example for your case should likely be:
{code}
private static final JexlEngine jexl = new JexlEngine();
static {
   jexl.setCache(512);
   jexl.setLenient(false);
   jexl.setSilent(false);
}
{code}

About setLenient / setSilent;
- lenient/strict tells whether 'null' is a valid operand or not, ie what is considered an error
- silent/verbose drives whether errors are logged (as warnings) or reported as JexlExcepttion (runtime exceptions), ie what should be done with errors
I gather that http://commons.apache.org/jexl/apidocs/org/apache/commons/jexl2/JexlEngine.html javadoc is not clear enough on the topic.





> Documentation of Thread Safety / Invalid code examples on homepage
> ------------------------------------------------------------------
>
>                 Key: JEXL-99
>                 URL: https://issues.apache.org/jira/browse/JEXL-99
>             Project: Commons JEXL
>          Issue Type: Task
>    Affects Versions: 2.0
>            Reporter: Marcel Schoen
>            Priority: Minor
>
> I had trouble with a custom method invoked in a JEXL script. This method throws a RuntimeException, which got swallowed with JEXL 2. Using the debugger, I found the "strict" flag of the Interpreter to be false, even though I had invoked "JexlEngine.setLenient(false)" in my initialization code.
> Now I suspect my initialization logic to be faulty, but while I looked into this, I realized that the javadoc of JexlEngine doesn't really tell me if I can use it as a singleton or not (or if I should, for that matter). If so, are its various methods thread-safe or not? It only says so for a few methods like "setDebug()".
> In addition, some code examples on the homepage are heavily outdated. For example, the first code fragment on this page
> http://commons.apache.org/jexl/reference/examples.html
> shows the usage of a class "ExpressionFactory" which doesn't even exist in the JEXL 2 source tree. Of course it would be nice if these examples would show how to correctly use "JexlEngine", for instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (JEXL-99) Documentation of Thread Safety / Invalid code examples on homepage

Posted by "Henri Biestro (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JEXL-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Biestro resolved JEXL-99.
-------------------------------

    Resolution: Fixed

Updated javadoc and example.

Committed revision 927136.
 xdocs/reference/examples.xml
 src/main/java/org/apache/commons/jexl2/JexlEngine.java



> Documentation of Thread Safety / Invalid code examples on homepage
> ------------------------------------------------------------------
>
>                 Key: JEXL-99
>                 URL: https://issues.apache.org/jira/browse/JEXL-99
>             Project: Commons JEXL
>          Issue Type: Task
>    Affects Versions: 2.0
>            Reporter: Marcel Schoen
>            Assignee: Henri Biestro
>            Priority: Minor
>             Fix For: 2.0.1
>
>
> I had trouble with a custom method invoked in a JEXL script. This method throws a RuntimeException, which got swallowed with JEXL 2. Using the debugger, I found the "strict" flag of the Interpreter to be false, even though I had invoked "JexlEngine.setLenient(false)" in my initialization code.
> Now I suspect my initialization logic to be faulty, but while I looked into this, I realized that the javadoc of JexlEngine doesn't really tell me if I can use it as a singleton or not (or if I should, for that matter). If so, are its various methods thread-safe or not? It only says so for a few methods like "setDebug()".
> In addition, some code examples on the homepage are heavily outdated. For example, the first code fragment on this page
> http://commons.apache.org/jexl/reference/examples.html
> shows the usage of a class "ExpressionFactory" which doesn't even exist in the JEXL 2 source tree. Of course it would be nice if these examples would show how to correctly use "JexlEngine", for instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JEXL-99) Documentation of Thread Safety / Invalid code examples on homepage

Posted by "Henri Biestro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JEXL-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12849222#action_12849222 ] 

Henri Biestro commented on JEXL-99:
-----------------------------------

Cache unit is expression; jexl.setCache(512); makes it cache 512 expressions/scripts.

The cache itself (as all JEXL caches) is held through a SoftReference; if memory pressure raises, it may be collected and avoid participating in an OOM.

> Documentation of Thread Safety / Invalid code examples on homepage
> ------------------------------------------------------------------
>
>                 Key: JEXL-99
>                 URL: https://issues.apache.org/jira/browse/JEXL-99
>             Project: Commons JEXL
>          Issue Type: Task
>    Affects Versions: 2.0
>            Reporter: Marcel Schoen
>            Assignee: Henri Biestro
>            Priority: Minor
>             Fix For: 2.0.1
>
>
> I had trouble with a custom method invoked in a JEXL script. This method throws a RuntimeException, which got swallowed with JEXL 2. Using the debugger, I found the "strict" flag of the Interpreter to be false, even though I had invoked "JexlEngine.setLenient(false)" in my initialization code.
> Now I suspect my initialization logic to be faulty, but while I looked into this, I realized that the javadoc of JexlEngine doesn't really tell me if I can use it as a singleton or not (or if I should, for that matter). If so, are its various methods thread-safe or not? It only says so for a few methods like "setDebug()".
> In addition, some code examples on the homepage are heavily outdated. For example, the first code fragment on this page
> http://commons.apache.org/jexl/reference/examples.html
> shows the usage of a class "ExpressionFactory" which doesn't even exist in the JEXL 2 source tree. Of course it would be nice if these examples would show how to correctly use "JexlEngine", for instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JEXL-99) Documentation of Thread Safety / Invalid code examples on homepage

Posted by "Henri Biestro (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JEXL-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Biestro updated JEXL-99:
------------------------------

    Fix Version/s: 2.0.1
         Assignee: Henri Biestro

> Documentation of Thread Safety / Invalid code examples on homepage
> ------------------------------------------------------------------
>
>                 Key: JEXL-99
>                 URL: https://issues.apache.org/jira/browse/JEXL-99
>             Project: Commons JEXL
>          Issue Type: Task
>    Affects Versions: 2.0
>            Reporter: Marcel Schoen
>            Assignee: Henri Biestro
>            Priority: Minor
>             Fix For: 2.0.1
>
>
> I had trouble with a custom method invoked in a JEXL script. This method throws a RuntimeException, which got swallowed with JEXL 2. Using the debugger, I found the "strict" flag of the Interpreter to be false, even though I had invoked "JexlEngine.setLenient(false)" in my initialization code.
> Now I suspect my initialization logic to be faulty, but while I looked into this, I realized that the javadoc of JexlEngine doesn't really tell me if I can use it as a singleton or not (or if I should, for that matter). If so, are its various methods thread-safe or not? It only says so for a few methods like "setDebug()".
> In addition, some code examples on the homepage are heavily outdated. For example, the first code fragment on this page
> http://commons.apache.org/jexl/reference/examples.html
> shows the usage of a class "ExpressionFactory" which doesn't even exist in the JEXL 2 source tree. Of course it would be nice if these examples would show how to correctly use "JexlEngine", for instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JEXL-99) Documentation of Thread Safety / Invalid code examples on homepage

Posted by "Marcel Schoen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JEXL-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12849209#action_12849209 ] 

Marcel Schoen commented on JEXL-99:
-----------------------------------

Thanks for the quick answer. That already makes the important things clear for me. One more question though about the "JexlEngine.setCache()" method: What exactly is that size? Number of scripts? Kilobytes?

> Documentation of Thread Safety / Invalid code examples on homepage
> ------------------------------------------------------------------
>
>                 Key: JEXL-99
>                 URL: https://issues.apache.org/jira/browse/JEXL-99
>             Project: Commons JEXL
>          Issue Type: Task
>    Affects Versions: 2.0
>            Reporter: Marcel Schoen
>            Assignee: Henri Biestro
>            Priority: Minor
>             Fix For: 2.0.1
>
>
> I had trouble with a custom method invoked in a JEXL script. This method throws a RuntimeException, which got swallowed with JEXL 2. Using the debugger, I found the "strict" flag of the Interpreter to be false, even though I had invoked "JexlEngine.setLenient(false)" in my initialization code.
> Now I suspect my initialization logic to be faulty, but while I looked into this, I realized that the javadoc of JexlEngine doesn't really tell me if I can use it as a singleton or not (or if I should, for that matter). If so, are its various methods thread-safe or not? It only says so for a few methods like "setDebug()".
> In addition, some code examples on the homepage are heavily outdated. For example, the first code fragment on this page
> http://commons.apache.org/jexl/reference/examples.html
> shows the usage of a class "ExpressionFactory" which doesn't even exist in the JEXL 2 source tree. Of course it would be nice if these examples would show how to correctly use "JexlEngine", for instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.