Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1263205

FlowLayout.layoutContainer() is not thread safe against Container.remove()

XMLWordPrintable

    • sparc
    • solaris_2.5

      FlowLayout.layoutContainer() does not protect itself against components being removed while it's iterating through its target's sub-components. An ArrayIndexOutOfBoundsException is raised.

      To reproduce:

      1) Visit http://wombat.eng/~brie/kona/thread/basher/BashTest.html
      2) Click "Start" about 20 times in very quick succession.
      3) Under normal or un-stressed circumstances, the status bar would return to "No bashing" after the death of every thread. However, if a thread dies due to this bug, it wouldn't decrement the count (which is handled after the validate()). Also, System.err displays:

      java.lang.ArrayIndexOutOfBoundsException: No such child: 8
              at java.awt.Container.getComponent(Container.java:72)
              at java.awt.FlowLayout.moveComponents(FlowLayout.java:172)
              at java.awt.FlowLayout.layoutContainer(FlowLayout.java:215)
              at java.awt.Container.layout(Container.java:250)
              at java.awt.Container.validateTree(Container.java:276)
              at java.awt.Container.validateTree(Container.java:282)
              at java.awt.Container.validateTree(Container.java:282)
              at java.awt.Container.validate(Container.java:265)
              at BasherApplet.run(BasherApplet.java:344)
              at java.lang.Thread.run(Thread.java)

      Since validate() is called by a window resize, and since validate() calls layoutContainer(), it could be triggered without using a contrived test.

            rramsunw Ranganathan Ram (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: