Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1922

AbstractTree - setting root to null causes NullPointerException

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.5
    • Fix Version/s: 1.3.7, 1.4-RC5
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      JDK 1.6.0_01

      Description

      I have TreeTable with some nodes, perform some filtering of them and update tree model. If result of filtering is nothing (empty Tree) I set setRoot(null) on the tree model. This send treeStructureChanged event to all listeners (to my TreeTable) with parameter TreeModelEvent which is constructed with null TreePath parameter. This cause NullPointerException in AbstractTree (implements TreeModelListener).
      I propose this fix:
      org.apache.wicket.markup.html.tree.AbstractTree

      /**

      • @see javax.swing.event.TreeModelListener#treeStructureChanged(javax.swing.event.TreeModelEvent)
        */
        public final void treeStructureChanged(TreeModelEvent e)
        {
        // empty root
        if(e.getTreePath() == null) { invalidateAll(); }


        else {
        // get the parent node of changed nodes
        TreeNode node = (TreeNode)e.getTreePath().getLastPathComponent();

      // has the tree root changed?
      if (e.getTreePath().getPathCount() == 1 && node.equals(rootItem.getModelObject()))

      { invalidateAll(); }

      else

      { invalidateNodeWithChildren(node); }

      }
      }

        Attachments

          Activity

            People

            • Assignee:
              knopp Matej Knopp
              Reporter:
              vlastimil.dolejs Vlastimil

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment