Announcement Announcement Module
Collapse
No announcement yet.
Is getValue() thread safe in SpEL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is getValue() thread safe in SpEL

    Hi,

    There are many items to be evaluated and there is only 1 expression.

    From doc, the ExpressionParser is thread-safe, while I'm not sure whether the Expression is thread-safe.

    Could I initialize the expression once and then use its getValue function in multiple threads?

    For example, I just want to invoke the following 'evaluate' function in multi-thread.

    public Class Test{

    private Expression exp;

    public Test(){
    ExpressionParser parser = new SpelExpressionParser();
    exp = parser.parseExpression("XXX");
    }

    public String evaluate(String item){
    String result= exp.getValue(item,String.class);
    return result;
    }
    }

    Thanks
    -zman

  • #2
    by looking at SpelExpression source, looks like getValue is thread safe

    Comment

    Working...
    X