]> source.dussan.org Git - jgit.git/commitdiff
Fix UnsupportedOperationException while fixing thin pack 19/1619/1
authorShawn O. Pearce <spearce@spearce.org>
Fri, 17 Sep 2010 16:11:26 +0000 (09:11 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 17 Sep 2010 16:13:34 +0000 (09:13 -0700)
If a thin pack has a large delta we need to be able to open
its cached copy from the loose object directory through the
CachedObjectDatabase handle.  Unfortunately that did not support the
openObject2 method, which the LargePackedDeltaObject used directly
to bypass looking at the pack files.

Bug: 324868
Change-Id: I1d5886a6c3254c6dea2852d50b8614c31a93e615
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/CachedObjectDirectory.java

index a5762b61ee8c0303a599f5ef29bd14e861d1f5ee..9bad71d8d70985712723207969d8b72fe5124447 100644 (file)
@@ -187,15 +187,15 @@ class CachedObjectDirectory extends FileObjectDatabase {
 
        @Override
        boolean hasObject2(String objectId) {
-               // This method should never be invoked.
-               throw new UnsupportedOperationException();
+               return unpackedObjects.contains(ObjectId.fromString(objectId));
        }
 
        @Override
        ObjectLoader openObject2(WindowCursor curs, String objectName,
                        AnyObjectId objectId) throws IOException {
-               // This method should never be invoked.
-               throw new UnsupportedOperationException();
+               if (unpackedObjects.contains(objectId))
+                       return wrapped.openObject2(curs, objectName, objectId);
+               return null;
        }
 
        @Override
@@ -208,8 +208,9 @@ class CachedObjectDirectory extends FileObjectDatabase {
        @Override
        long getObjectSize2(WindowCursor curs, String objectName, AnyObjectId objectId)
                        throws IOException {
-               // This method should never be invoked.
-               throw new UnsupportedOperationException();
+               if (unpackedObjects.contains(objectId))
+                       return wrapped.getObjectSize2(curs, objectName, objectId);
+               return -1;
        }
 
        @Override