novitski / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
Apache License 2.0
0 stars 0 forks source link

NullPointerException in BlockChain.findSplit() #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From time to time, I get the following exception reported by users:

java.lang.NullPointerException
at com.google.bitcoin.core.BlockChain.findSplit(BlockChain.java:292)
at com.google.bitcoin.core.BlockChain.connectBlock(BlockChain.java:219)
at com.google.bitcoin.core.BlockChain.add(BlockChain.java:191)
at com.google.bitcoin.core.BlockChain.add(BlockChain.java:124)
at com.google.bitcoin.core.Peer.processBlock(Peer.java:187)
at com.google.bitcoin.core.Peer.run(Peer.java:130)
at 
com.google.bitcoin.core.PeerGroup$PeerExecutionRunnable$1.run(PeerGroup.java:246
)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)

It looks like BlockChain.chainHead can sometimes be null.

Original issue reported on code.google.com by andreas....@gmail.com on 16 Aug 2011 at 10:06

GoogleCodeExporter commented 9 years ago
Hmm, that line could be caused by one of two objects being null.

Original comment by hearn@google.com on 16 Aug 2011 at 10:08

GoogleCodeExporter commented 9 years ago
Really? We're talking about

while (!currentChainCursor.equals(newChainCursor))

IMHO if newChainCursor were null, the exception would be thrown inside 
currentChainCursor.equals(). So it can only be currentChainCursor being null.

(The other thing to worry about in this context is autoboxing, but there are no 
native types involved here)

Original comment by andreas....@gmail.com on 16 Aug 2011 at 10:47

GoogleCodeExporter commented 9 years ago
Ah yeah, you're right.

Original comment by hearn@google.com on 16 Aug 2011 at 10:52

GoogleCodeExporter commented 9 years ago

Original comment by mi...@google.com on 14 Oct 2011 at 9:36

GoogleCodeExporter commented 9 years ago
This didn't happen for a long time now.

Original comment by hearn@google.com on 19 Sep 2012 at 3:17