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

WebHistory: java.lang.ArrayIndexOutOfBoundsException exception is thrown when setting a history maximum size to a newly created WebEngine

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7u6
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
      web

      Description

      When using engine.getHistory().setMaxSize() for a newly created WebEngine, an exception is thrown:

      java.lang.ArrayIndexOutOfBoundsException: -1
      at java.util.ArrayList.elementData(ArrayList.java:371)
      at java.util.ArrayList.get(ArrayList.java:384)
      at com.sun.javafx.collections.ObservableListWrapper.get(Unknown Source)
      at javafx.scene.web.WebHistory$1.stateChanged(Unknown Source)
      at com.sun.webpane.platform.BackForwardList.notifyChanged(Unknown Source)
      at com.sun.webpane.platform.BackForwardList.bflSetMaximumSize(Native Method)
      at com.sun.webpane.platform.BackForwardList.setMaximumSize(Unknown Source)
      at javafx.scene.web.WebHistory.setMaxSize(Unknown Source)
      at testmaxsize.TestMaxSize.start(TestMaxSize.java:47)
      at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$3.run(Unknown Source)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
      at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:722)
      Exception in thread "JavaFX Application Thread"

      However, setMaxSize call is successful, and maxSize changes to a new value.
      This doesn't happen after anything is loaded.

      Please use the following code snippet to reproduce the problem (comment out either section 1 or section 2 to observe the behaviour):
      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.concurrent.Worker;
      import javafx.concurrent.Worker.State;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class TestMaxSize extends Application {

          public static void main(String[] args) {
              System.setProperty("proxyHost", "www-proxy.us.oracle.com");
              System.setProperty("proxyPort", "80");
              launch(args);
          }
          
          @Override
          public void start(Stage primaryStage) {
              WebView view = new WebView();
              final WebEngine engine = view.getEngine();

              // Section 1: no exception
      // engine.load("http://google.com");
      // engine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
      // @Override
      // public void changed(ObservableValue<? extends State> arg0, State arg1, State arg2) {
      // if (arg2.equals(State.SUCCEEDED))
      // engine.getHistory().setMaxSize(94);
      // System.out.println(engine.getHistory().getMaxSize());
      // }
      // });
              // End of section 1
              
              // Section 2: exception
              engine.getHistory().setMaxSize(94);
              System.out.println(engine.getHistory().getMaxSize());
              // End of section 2
              
              primaryStage.setScene(new Scene(view, 300, 250));
              primaryStage.show();
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ant Anton Tarasov
                Reporter:
                ilatyshe Irina Grineva (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: