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

TabOrderHelper.findNextFocusablePeer() will throw a NullPointerException when a parent peer is not found

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: openjfx11, openjfx15, openjfx16
    • Fix Version/s: None
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Bug should not occur on all platforms, was discovered using Windows and Java 11.0.2

      A DESCRIPTION OF THE PROBLEM :
      com.sun.javafx.scene.traversal.TabOrderHelper.findNextFocusablePeer() will throw a NullPointerException when a parent peer is not found. It should returning null instead. The while loop gets the parent and checks it for null. If it is null, the startNode is set to null. The next iteration of the loop calls startNode.getParent() and throws a NPE. I suggest adding a simple null check to avoid this.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Call TabOrderHelper.findNextFocusablePeer() with a node without a focusable peer.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Null should be returned
      ACTUAL -
      NullPointerException thrown

      ---------- BEGIN SOURCE ----------
      import com.sun.javafx.scene.traversal.Direction;
      import com.sun.javafx.scene.traversal.TopMostTraversalEngine;

      import javafx.application.Application;
      import javafx.scene.Node;
      import javafx.scene.Parent;
      import javafx.scene.control.Button;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class TabOrderHelperNPE extends Application
      {
      public TabOrderHelperNPE()
      {
      super();
      }

      @Override
      public void start(Stage primaryStage) throws Exception
      {
      Node node = new Button();
      node.setFocusTraversable(false);
      Pane pane = new StackPane(node);
      pane.setFocusTraversable(false);

      TestTraversalEngine engine = new TestTraversalEngine(new StackPane());
      engine.trav(node, Direction.NEXT);
      }

      static class TestTraversalEngine extends TopMostTraversalEngine
      {
      private final Parent root;

      TestTraversalEngine(Parent root)
      {
      super();
      this.root = root;
      }

      @Override
      protected Parent getRoot()
      {
      return this.root;
      }
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known

      FREQUENCY : always


        Attachments

          Activity

            People

            Assignee:
            arapte Ambarish Rapte
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: