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

NPE in JFXPanel$HostContainer#setEmbeddedStage

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Backports

        Description

        FULL PRODUCT VERSION :
        ava version "1.8.0_112"
        Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
        Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Dell Latitude E7440

        A DESCRIPTION OF THE PROBLEM :
        In my company we are embedding JavaFX controls into an already existing Swing application using a JFXPanel.

        For a weird reason and without being able to provide you any particular test-case nor code snippet, I noticed that very often a NPE was thrown in the traces:

        E!com.*********.util.log.uncaught ERROR [2017-02-01 21:20:06,897] [AWT-EventQueue-1] [] {}
        M!Uncaught exception: thread=AWT-EventQueue-1
        java.lang.NullPointerException
        at javafx.embed.swing.JFXPanel$HostContainer.lambda$setEmbeddedStage$52(JFXPanel.java:864)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at com.*********.util.operation.SessionEventQueue.dispatchEvent(AWTEvent)(SessionEventQueue.java:80)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

        While investigating the JDK code throwing this exception, I noticed that there was a nulllity check on stagePeer variable performed before enqueuing an action using it through a lambda in the AWT Event Queue.

        In some situations, stagePeer variable seems to be resetted to null in the meantime, which throws the exception below.

        Here's my suggested patch to fix that: shouldn't the nullity check also be present within the lambda to ensure stagePeer variable won't be nullified in between?

        There has already been a similar fix for JFXPanel$HostContainer#setEmbeddedScene method fixed in Java8u60 as described here: https://bugs.openjdk.java.net/browse/JDK-8097368

        So far, I haven't seen any consequences of this exception in the UI itself but I guess NPEs are never desired.

        If this seems to be a valid use-case, could you try to fix it somehow?

        Thanks in advance.

        Regards

        Fourfour


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Embedding JavaFX controls within a Swing application using a JFXPanel.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        No NPE in the traces.
        ACTUAL -
        NPE thrown.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        E!com.*********.util.log.uncaught ERROR [2017-02-01 21:20:06,897] [AWT-EventQueue-1] [] {}
        M!Uncaught exception: thread=AWT-EventQueue-1
        java.lang.NullPointerException
        at javafx.embed.swing.JFXPanel$HostContainer.lambda$setEmbeddedStage$52(JFXPanel.java:864)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at com.*********.util.operation.SessionEventQueue.dispatchEvent(AWTEvent)(SessionEventQueue.java:80)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

        REPRODUCIBILITY :
        This bug can be reproduced often.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ssadetsky Semyon Sadetsky
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Due:
                    Created:
                    Updated:
                    Resolved: