import java.io.IOException;
+import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.storage.pack.ObjectReuseAsIs;
* @return a {@link ObjectLoader} for accessing the object.
* @throws MissingObjectException
* the object does not exist.
+ * @throws IncorrectObjectTypeException
+ * typeHint was not OBJ_ANY, and the object's actual type does
+ * not match typeHint.
* @throws IOException
*/
public abstract ObjectLoader openObject(AnyObjectId objectId, int typeHint)
- throws MissingObjectException, IOException;
+ throws MissingObjectException, IncorrectObjectTypeException, IOException;
/**
* Release any resources used by this reader.
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
+import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException;
import org.eclipse.jgit.lib.AnyObjectId;
}
public ObjectLoader openObject(AnyObjectId objectId, int typeHint)
- throws MissingObjectException, IOException {
+ throws MissingObjectException, IncorrectObjectTypeException,
+ IOException {
final ObjectLoader ldr = db.openObject(this, objectId);
if (ldr == null) {
if (typeHint == OBJ_ANY)
throw new MissingObjectException(objectId.copy(), "unknown");
throw new MissingObjectException(objectId.copy(), typeHint);
}
+ if (typeHint != OBJ_ANY && ldr.getType() != typeHint)
+ throw new IncorrectObjectTypeException(objectId.copy(), typeHint);
return ldr;
}