Click
  1. Click
  2. CLK-713

Race condition in Menu.getHeadElements

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.0-M1
    • Component/s: extras
    • Labels:
      None

      Description

      Multi threads can access a cached Menu while it is being initialized. The Exception can be:

      java.lang.ArrayIndexOutOfBoundsException: 2
      at java.util.ArrayList.add(ArrayList.java:352)
      at org.apache.click.extras.control.Menu.getHeadElements(Menu.java:1077)
      at org.apache.click.util.PageImports.processControl(PageImports.java:37

      Initializing the menu in MenuFactory by calling menu.getHeadElements() seems to make the race condition go away.

        Activity

        Hide
        Bob Schellink added a comment -

        Thanks Finn, your solution of invoking getHeadElements from getRootMenu looks good. I've committed to trunk.

        Show
        Bob Schellink added a comment - Thanks Finn, your solution of invoking getHeadElements from getRootMenu looks good. I've committed to trunk.
        Hide
        Bob Schellink added a comment -

        We should probably synchronize the MenuFactory.getRootMenu but ensure it is efficient. I haven't look to deeply at JDK5 concurrency support but something like the FutureTask might be useful here.

        Unless someone beats me to it I'll have a look at this over the weekend.

        Show
        Bob Schellink added a comment - We should probably synchronize the MenuFactory.getRootMenu but ensure it is efficient. I haven't look to deeply at JDK5 concurrency support but something like the FutureTask might be useful here. Unless someone beats me to it I'll have a look at this over the weekend.

          People

          • Assignee:
            Bob Schellink
            Reporter:
            Finn Bock
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development