]> source.dussan.org Git - jgit.git/commitdiff
DHT: Fix NPE during prefetch 05/3705/1
authorShawn O. Pearce <spearce@spearce.org>
Thu, 9 Jun 2011 23:56:53 +0000 (16:56 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 10 Jun 2011 00:29:46 +0000 (17:29 -0700)
The Prefetcher may have loaded a chunk that is a fragment, if the
DhtReader is scanning the Prefetcher's chunks for a particular
object fragment chunks will be missing the index and NPE during
the findOffset() call into the index itself.

Change-Id: Ie2823724c289f745655076c5209acec32361a1ea
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/PackChunk.java

index c0684022f3ead32798fbf3bbbbb44cc9000abee5..66d3d3386bbd7c246589699ea68fddc24748cda9 100644 (file)
@@ -291,7 +291,7 @@ public final class PackChunk {
        }
 
        int findOffset(RepositoryKey repo, AnyObjectId objId) {
-               if (key.getRepositoryId() == repo.asInt())
+               if (key.getRepositoryId() == repo.asInt() && index != null)
                        return index.findOffset(objId);
                return -1;
        }