Commons OGNL
  1. Commons OGNL
  2. OGNL-226

Race condition with OgnlRuntime.getMethod

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Not A Problem
    • Affects Version/s: 3.0
    • Fix Version/s: 4.0
    • Component/s: Core Runtime
    • Labels:
      None
    • Flags:
      Patch

      Description

      If there are two consecutive calls to OgnlRuntime.getMethod before the result is cached it may erroneously return null.

        Activity

        Hide
        Johno Crawford added a comment - - edited

        Attaching test case, if you run it several times it should yield the following exception (maybe 1 in 15 if you are unlucky)..

        Exception in thread "main" java.lang.AssertionError: expected:<true> but was:<false>
        at org.junit.Assert.fail(Assert.java:93)
        at org.junit.Assert.failNotEquals(Assert.java:647)
        at org.junit.Assert.assertEquals(Assert.java:128)
        at org.junit.Assert.assertEquals(Assert.java:147)
        at OgnlRuntimeTest.runTest(OgnlRuntimeTest.java:32)
        at OgnlRuntimeTest.main(OgnlRuntimeTest.java:22)

        Show
        Johno Crawford added a comment - - edited Attaching test case, if you run it several times it should yield the following exception (maybe 1 in 15 if you are unlucky).. Exception in thread "main" java.lang.AssertionError: expected:<true> but was:<false> at org.junit.Assert.fail(Assert.java:93) at org.junit.Assert.failNotEquals(Assert.java:647) at org.junit.Assert.assertEquals(Assert.java:128) at org.junit.Assert.assertEquals(Assert.java:147) at OgnlRuntimeTest.runTest(OgnlRuntimeTest.java:32) at OgnlRuntimeTest.main(OgnlRuntimeTest.java:22)
        Hide
        Johno Crawford added a comment -
        Show
        Johno Crawford added a comment - PR with fix at https://github.com/jkuhnert/ognl/pull/4
        Hide
        Lukasz Lenart added a comment -

        Pull request accepted, should it be applied to Apache OGNL ?

        Show
        Lukasz Lenart added a comment - Pull request accepted, should it be applied to Apache OGNL ?
        Hide
        Johno Crawford added a comment -

        Nope, bug does not exist in Apache OGNL. Also ignore my statement about ConcurrentHashMap, looks like it is used inside a wrapper (falls back to normal HashMap + sync if below JDK 1.5).

        Show
        Johno Crawford added a comment - Nope, bug does not exist in Apache OGNL. Also ignore my statement about ConcurrentHashMap, looks like it is used inside a wrapper (falls back to normal HashMap + sync if below JDK 1.5).

          People

          • Assignee:
            Unassigned
            Reporter:
            Johno Crawford
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development