NPEs in Playback

Help
2008-07-01
2012-12-04
  • Rob Davison
    Rob Davison
    2008-07-01

    Hi KD and Marathon users.

    Sorry for cross-posting... I originally made some posts in the 'bugs' list, although it doesn't look like that is used much anymore, so I have reposted here.

    I have two null pointer exceptions during playback. I have tried adding sleep(x) before and after, but this does not cure the issue.

    1)
    This was first mentioned by bcp2001 here http://sourceforge.net/tracker/index.php?func=detail&aid=1765061&group_id=46616&atid=446764

    Has anyone else experienced this? Is there a resolution/workaround?

    2)
    From my original post here http://sourceforge.net/tracker/index.php?func=detail&aid=2002511&group_id=46616&atid=446764
    Again, tried to add sleep(x).
    This one happens in different places during playback, so its a little odd.

    java.lang.NullPointerException
    at
    javax.swing.plaf.basic.BasicGraphicsUtils.isLeftToRight(BasicGraphicsUtils.
    java:287)
    at
    javax.swing.plaf.basic.BasicMenuItemUI.layoutMenuItem(BasicMenuItemUI.java:
    849)
    at
    javax.swing.plaf.basic.BasicMenuItemUI.paintMenuItem(BasicMenuItemUI.java:5
    80)
    at
    com.jgoodies.looks.common.ExtBasicMenuUI.paintMenuItem(ExtBasicMenuUI.java:
    140)
    at
    com.jgoodies.looks.plastic.PlasticMenuUI.paintMenuItem(PlasticMenuUI.java:9
    7)
    at javax.swing.plaf.basic.BasicMenuItemUI.paint(BasicMenuItemUI.java:514)
    at
    javax.swing.plaf.basic.BasicMenuItemUI.update(BasicMenuItemUI.java:510)
    at javax.swing.JComponent.paintComponent(JComponent.java:743)
    at javax.swing.JComponent.paint(JComponent.java:1006)
    at javax.swing.JComponent.paintChildren(JComponent.java:843)
    at javax.swing.JComponent.paint(JComponent.java:1015)
    at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4972)
    at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
    at javax.swing.JComponent._paintImmediately(JComponent.java:4868)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4675)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
    at
    javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQ
    ueueUtilities.java:114)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at
    java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.j
    ava:242)
    at
    java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.jav
    a:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    Marathon is a great product, but as you can imagine, we can't run an overnight regression batch at the moment as a few of these NPEs at the beginning of a test will cause the remainder of it to fail!

    Once again, sorry for cross-posting and thanks for your help in advance :-)
    Rob

     
    • Rob Davison
      Rob Davison
      2008-07-02

      Hmm, I think issue 1) has been asked on the JGoodies forum here:
      https://looks.dev.java.net/issues/show_bug.cgi?id=181
      So I have asked this user if the workaround was successful.

       
    • Hi all,

      I don't understand if problem 1) or 2) are related (caused by the same bug) but I also get NPE when testing my app which opens screen forms on menu selection. What is most strange is that it not occurs every time, sometimes test replay works fine and most of the time it breaks as soon as it selects menu item. I get 3 kinds of NPE:

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1220)
          at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1261)

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicGraphicsUtils.isLeftToRight(BasicGraphicsUtils.java:287)
          at javax.swing.plaf.basic.BasicMenuItemUI.layoutMenuItem(BasicMenuItemUI.java:929)

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicMenuItemUI.getMenuItemParent(BasicMenuItemUI.java:400)
          at javax.swing.plaf.basic.BasicMenuItemUI.layoutMenuItem(BasicMenuItemUI.java:919)

      I get the same exceptions with my app and with swing demo apps that use menus.

      So you say that this may be JGoodies problem after all? Would it help if Marathon L&F is set to Java's default L&F? I would try it but I am afraid that some Marathon functionality may be tied to JGoodies. Can anyone from Marathon dev team comment on L&F change?

      Thanks,

      Dario

       
    • SF is having some weird problems and not forwarding the mails to my gmail account. So the monitoring of the forum is some what of a pain as of now.

      The problem is that I was not able to reproduce the NPEs. Can you post a sample where I can reproduce the same? Marathon should not launch the AUT with looks enabled. I think over a period of time that was relaxed a little bit, and Marathon AUT runner is also using the looks at some places. I will check it out and try to remove the dependency. This, to me, seems to be a complete fix.

      Thanks and Regards
      KD

       
    • Hello KD,

      Here are couple of hints how to reproduce the problem. I tested Metalworks application from JDK demos, it is very simple marathon project setup. I recorded a test using default fixture. Test opens "File" menu and selects "New", at that point exception is thrown. L&F of AUT is default Ocean, so it is not changed by marathon. Here is my test:

      useFixture(default)

      def test():
          java_recorded_version = '1.6.0_04'

          if window('Metalworks'):
              select_menu('File>>New')
              select('TextField', 'name@mail.com')
              select('TextField1', 'test')
              select('TextArea', 'lorem ipsum...')
              click('BasicInternalFrameTitlePane$NoFocusButton2')
          close()

      There is no point to post project properties, they are very simple and contain only classpath, working dir and java  executable. Marathon version is 1.2. I hope this will help you reproduce the problem.

      Thank you for your time!

      Dario

       
    • Rob Davison
      Rob Davison
      2008-07-04

      Hi All,

      With regards to issue 1) I contacted the user who reported this on the JGoodies forum. His workaround was this:

      See the classes ExtBasicMenuUI and ExtBasicMenuItemUI in the
      com.jgoodies.looks.common. The methods getPreferredMenuItemSize and
      paintMenuItemm, both classes, rely on the mentioned renderer.

      Insert the following in both methods of both classes (4 times):

      if (renderer == null) {
      System.err.println("Renderer is null!");
      installDefaults();
      }

      We recompiled the JGoodies lib and so far so good. However we occasionally get this exception instead:

      java.lang.NullPointerException
              at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1051)
              at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1092)
              at java.awt.Component.processMouseEvent(Component.java:5517)
              at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
              at java.awt.Component.processEvent(Component.java:5282)
              at java.awt.Container.processEvent(Container.java:1966)
              at java.awt.Component.dispatchEventImpl(Component.java:3984)
              at java.awt.Container.dispatchEventImpl(Container.java:2024)
              at java.awt.Component.dispatchEvent(Component.java:3819)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
              at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

      The basic code is right clicking on table entries and selecting an item from the menu:

      select('TabbedPane', '<html><center><b>Results Detail</b><sup><font size=-3 color=red></html>')
              select('NiceTable', 'cell:Name,4(Company name)')
              rightclick('NiceTable', 'Name,4')
              select_menu('Chart')
              select('NiceTable', 'cell:Name,4(Company name)')

              if window('Chart'):
                  click('Close')
              close()

              select('NiceTable', 'cell:Name,7(Company name)')
              rightclick('NiceTable', 'Name,7')
              select_menu('Create Chart>>Today')
              select('NiceTable1', 'cell:Name,7(Company name)')

              if window('Importing data'):
                  click('OK')
              close()

      ----------

      With issue 2 (leftToRight exception) this also occurs much less with the workaround. This is simply from selecting an item from a main menu.

      So the JGoodies fix has almost resolved my issues, but if KD can also disable the looks that would be appreciated.

      Thanks for your time guys.
         

       
    • John
      John
      2008-07-08

      I attempted the suggested JGoodies fix with no luck, however I have noticed that adding/increasing delays between the PostEvent calls in the 'fire' function of the FireableMouseClick.java file reduces the frequency with which I run into problems.  I suspect that there is a race condition between the postEvent calls, and sub-events fired off by the postEvent calls.  If the sub-events do not fire before the remaining postEvents, then they may not have run the installUI function in BasicMenuItemUI.class, which sets the menuItem variable to a non-null value.  If menuItem is still null when the MouseEvent.MOUSE_RELEASED is fired, it throws a nullPointerException.
      Although adding delays between the postEvents does reduce the frequency of the problem, it does not solve the underlying issue, which is the race condition.  To truly solve this problem, there would need to be some way to guarantee that all sub-events of MouseEvent.MOUSE_PRESSED had completed before MouseEvent.MOUSE_RELEASED was posted, and that all of its sub-events completed before the next event was posted, etc.

       
    • jason
      jason
      2008-07-09

      I recently upgraded from marathon 1.1.3 to marathon 1.2.0 and have found that when clicking twice in succession or double clicking on a component custom component I created which extends JTree will always produce this NPE.

      UncaughtException
      SEVERE: !!! Uncaught Exception in Thread AWT-EventQueue-0: java.lang.NullPointerException
      java.lang.NullPointerException
          at javax.swing.plaf.basic.BasicTreeUI.paintRow(Unknown Source)
          at javax.swing.plaf.basic.BasicTreeUI.paint(Unknown Source)
          at javax.swing.plaf.ComponentUI.update(Unknown Source)
          at javax.swing.JComponent.paintComponent(Unknown Source)
          at javax.swing.JComponent.paint(Unknown Source)
          at javax.swing.JComponent.paintToOffscreen(Unknown Source)
          at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
          at javax.swing.RepaintManager.paint(Unknown Source)
          at javax.swing.JComponent._paintImmediately(Unknown Source)
          at javax.swing.JComponent.paintImmediately(Unknown Source)
          at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
          at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
          at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
          at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
          at java.awt.event.InvocationEvent.dispatch(Unknown Source)
          at java.awt.EventQueue.dispatchEvent(Unknown Source)
          at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at java.awt.EventDispatchThread.run(Unknown Source)

      any suggestions on how to overcome this issue would be greatly appreciated.
       

       
      • Is it happening during recording or playing?

        -- KD

         
    • jason
      jason
      2008-07-10

      This is only happening during play back. I tried writing a resolver to extend the MTree with println statements in each of the methods. the NPE occurs after “getComponent()” is called. I don’t think that the error is how component is getting resolved not sure what to try next. if you have any suggestions on how to debug marathon code better then using println statements it would be very helpful. Thxs.

       
      • Better way is to test it using unit tests. The problem with Marathon is that it launches a VM to run the AUT, so using a debugger we can't test the VM that is running the AUT. But the UTs can be debugged that way.

        -- KD

        PS: You should be able to import Marathon as a project into eclipse.

         
    • united
      united
      2008-07-25

      Hi everyone,

      I manage to fix the NPE problems encountered during playback:

      If you look at the MComponent.java class in the source code you will find at line 375 Marathon calls java to update the ui. I disabled this option and recompiled the code and ran the tests and they all work fine now. See my solution below:

              swingWait();
              new FireableMouseClickEvent(getComponent(), numberOfClicks, (modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0)
                      .fire(position, numberOfClicks, modifiers);
              if (true)
                  System.err.println("WARNING: Marathon's updateUI call in MComponent disabled");
              else if (getComponent() instanceof JComponent)
                  ((JComponent) getComponent()).updateUI();

      I don't know why were were calling updateUI() on the components why is it there even in the first place it would be nice to know.

      Regards,

      Mustafa

       
      • It was there from long time - I myself do not know why it is there. One reason it was overlooked is because I was confident that the NPE was because of some Swing/Looks issue. That shows why we should not be confident of our own code ;-).

        -- KD

         
    • This is good news indeed and worth a new release :-).

      Can someone else who have the access to the code and having the same problem confirm this?

      -- KD

       
    • Rob Davison
      Rob Davison
      2008-07-25

      Hi KD and Mustafa - thanks for this fix.

      We shall compile the code now and give it a go. The only way we can tell for sure is by running a large batch of files (can take a few hours...)

      KD - will the issue with 1.4 playback option be in your next release? (https://sourceforge.net/forum/forum.php?thread_id=2086810&forum_id=152821)

      Cheers,

      Rob

       
    • Rob Davison
      Rob Davison
      2008-07-25

      Hi All,

      So far, so good - not one NPE. I'll run a full regression over the weekend to make sure.

      Many many thanks for this!!

      Rob

       
      • Any update?

        -- KD

         
        • Rob Davison
          Rob Davison
          2008-07-29

          No NPEs over the last few days, so appears to be fixed for me :-)

           
          • Nice to hear that.

            Thanks should go to mustafa :)

            -- KD