BinaryHeap NullPointerException
See original GitHub issueIssue details
In prev release 7 march (gdx-1.9.11-SNAPSHOT) my game worked fine
Reproduction steps/code
BinaryHeap<Node> bh = new BinaryHeap<Node>();
bh.add(new Node(5f));
Node node = new Node(10f);
bh.add(node);
bh.remove(node);
bh.remove(node);
Version of LibGDX and/or relevant dependencies
gdx-1.9.11-SNAPSHOT gdx-ai-1.8.2
Stacktrace
java.lang.NullPointerException:
at com.badlogic.gdx.utils.BinaryHeap.down (BinaryHeap.java:156)
at com.badlogic.gdx.utils.BinaryHeap.remove (BinaryHeap.java:102)
at com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder.visitChildren (IndexedAStarPathFinder.java:219)
at com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder.search (IndexedAStarPathFinder.java:117)
at com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder.searchNodePath (IndexedAStarPathFinder.java:94)
at com.tpwar.game.maps.pathfinding.TiledPathFinder.find (TiledPathFinder.java:29)
at com.tpwar.game.screens.MapScreen$InputAdapterExtension.touchUp (MapScreen.java:741)
at com.badlogic.gdx.InputMultiplexer.touchUp (InputMultiplexer.java:124)
at com.badlogic.gdx.backends.android.AndroidInput.processEvents (AndroidInput.java:406)
at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame (AndroidGraphics.java:476)
at android.opengl.GLSurfaceView$GLThread.guardedRun (GLSurfaceView.java:1581)
at android.opengl.GLSurfaceView$GLThread.run (GLSurfaceView.java:1280)
Please select the affected platforms
- Android
- iOS (robovm)
- iOS (MOE)
- HTML/GWT
- Windows
- Linux
- MacOS
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Binary Heap – Data Structure - The Null Pointer Exception
A binary Heap is an array object. We can view that array object as a near complete binary tree. A binary tree is...
Read more >NullPointerException when inserting into binary heap?
I'm trying to insert values into an initially empty binary heap. This is the relevant code: public class minHeap { int[] array; int...
Read more >Null Pointer exception when extracting dump from core file ...
No translations currently exist. Issue. Cannot extract heap dump from core file with Java 11, using the following command: $JAVA_HOME/bin/jhsdb ...
Read more >[Solved]-NullPointerException when inserting into binary heap?-Java
On your first insert, hole = 0 but obviously x is equal to array[hole/2] since hole/2 evaluates to 0, so this loop exits...
Read more >BPEL - Failed to handle dispatch message ... exception ...
Hi, When I try to send a message to a BPEL process, it gives me a NullPointerException. ... BinaryHeap$MinComparator.compare(BinaryHeap.java:308)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes! Not only can I confirm the bug, I can confirm a fix for the bug, and it only needs moving one line in BinaryHeap! The solution is to change, in BinaryHeap.remove(T):
to
I believe the issue happened when
size
andnode.index
were equal, sonodes[node.index]
should have beenmoved
but instead wasnull
.Ah, that was tricky! Great find @tommyettinger!