Yeah, I wrote that and recently found out the reasons why it's faulty --
stupid memory model :)

Can you file a bug on this?

-Pat


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Micha³ Mosiewicz
Sent: Tuesday, October 07, 2003 4:01 AM
To: opensymphony-webwork
Subject: [OS-webwork] Bug catching contest...

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



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to