This code won't work as you would expect. It's that kind of bug you wouldn't
expect, but also that kind that should be taught on every programming course
(rare).

For those who are impatient and don't want to find out why it won't work I
suggest googling for "double checked locking" or DCL. Due to java memory
model (as matter of fact it's not only java) the code below doesn't work.

I strongly suggest to pass xwork/webwork through checkstyle. I suppose there
might be more. Of course - in this place it doesn't really matter if it
synchronized or not - it's just a matter of optimisation. But the same idiom
might be multiplied.

OgnlUtil.compile():

  public static Object compile(String expression) throws OgnlException {
        Object o = null;

        o = expressions.get(expression);

        if (o == null) {
            synchronized (expressions) {
                o = expressions.get(expression);

                if (o == null) {
                    o = Ognl.parseExpression(expression);
                    expressions.put(expression, o);
                }
            }
        }

        return o;
    }


-- Mike



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to