Menu

#4297 Possible NPE in MovePath.findPathTo

stable 0.42
closed
None
fixed
1
2015-01-28
2014-11-12
No

This was an ancillary issue in [#4291]. The following log information comes from the 39.2 MM release:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at megamek.common.MovePath.findPathTo(MovePath.java:793)
at megamek.client.ui.swing.MovementDisplay.currentMove(MovementDisplay.java:1273)
at megamek.client.ui.swing.MovementDisplay.hexMoused(MovementDisplay.java:1386)
at megamek.client.ui.swing.boardview.BoardView1.processBoardViewEvent(BoardView1.java:821)
at megamek.client.ui.swing.boardview.BoardView1.mouseAction(BoardView1.java:3589)
at megamek.client.ui.swing.boardview.BoardView1.mouseAction(BoardView1.java:3607)
at megamek.client.ui.swing.boardview.BoardView1.mousePressed(BoardView1.java:3316)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)

When I looked at the code, it seemed like it was possible that the greedy shortest path implementation was returning a null path, and that wasn't being handled properly.

Related

Bugs: #4291

Discussion

  • Dylan Myers

    Dylan Myers - 2014-12-18
    • Milestone: stable 0.40 --> post-stable 0.40
     
  • Nicholas Walczak

    • Milestone: post-stable 0.40 --> stable 0.40
     
  • Nicholas Walczak

    • Milestone: stable 0.40 --> stable 0.42
     
  • Nicholas Walczak

    • assigned_to: saginatio --> Nicholas Walczak
     
  • Nicholas Walczak

    [r11581].

    I kind of had to punt on this one. I can see what's going on: if the path planner can't find a path to the destination, it will return null. If a null path gets returned by the greedy path planner, then it will lead to the reported NPE.

    However, I can't figure out what conditions will lead to a null path being returned. I know that if there's not path to the destination, it a null path is returned, but it's not clear to me how to end up in a situation where the planner can't get to the destination.

    For now, I've added a null guard, and if the returned path is null, nothing happens. Additionally, some information is logged (unit, src and dest). This way, if we get a saved game where the error occurred, it may be easier to debug exactly what's going on.

    I'm going to close this ticket, and we can link to it if we get more reports.

     

    Related

    Commit: [r11581]

  • Nicholas Walczak

    • Resolution: accepted --> fixed
     
  • Dylan Myers

    Dylan Myers - 2015-01-28
    • Status: open --> closed
     

Log in to post a comment.