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

JTree isExpanded should not call itself recursively

XMLWordPrintable

    • b12
    • x86
    • windows_xp

        FULL PRODUCT VERSION :
        java version "1.6.0_02"
        Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
        Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        JTree isExpanded(TreePath) is unnecessarily recursive. With the default stack size (or any reasonable size) a TreePath to a few thousand entries will lead to StackOverflowException. Trees are used to represent graphs, e.g., reference chains that can easily exceed this depth. isExpanded(TreePath) can be trivially rewritten as a loop.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        In a loop, lengthen a path by adding children to a branch of a tree, one per level, and keep calling isVisible() on the TreePath that represents the deepest child until you get StackOverflowException.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Some degradation in speed, but no exceptions.
        ACTUAL -
        StackOverflowException when isVisible(TreePath) calls isExpanded(TreePath).

        REPRODUCIBILITY :
        This bug can be reproduced always.

              alexp Alexander Potochkin (Inactive)
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: