Browse Source

Allow DfsReader to be subclassed

Necessary if a DFS implementation wants to override close()
to record DfsReaderIoStats.

Change-Id: I144575f9bf1abf2c1fd72030550c4f0795fcf44d
stable-4.9
Shawn Pearce 8 years ago
parent
commit
1513a5632d
  1. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java
  2. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
  4. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
  5. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java

@ -674,7 +674,7 @@ public class DfsGarbageCollectorTest {
private boolean isObjectInPack(AnyObjectId id, DfsPackFile pack)
throws IOException {
try (DfsReader reader = new DfsReader(odb)) {
try (DfsReader reader = odb.newReader()) {
return pack.hasObject(reader, id);
}
}

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java

@ -530,7 +530,7 @@ public class DfsInserter extends ObjectInserter {
}
private class Reader extends ObjectReader {
private final DfsReader ctx = new DfsReader(db);
private final DfsReader ctx = db.newReader();
@Override
public ObjectReader newReader() {
@ -647,7 +647,7 @@ public class DfsInserter extends ObjectInserter {
@Override
public ObjectStream openStream() throws IOException {
final DfsReader ctx = new DfsReader(db);
final DfsReader ctx = db.newReader();
if (srcPack != packKey) {
try {
// Post DfsInserter.flush() use the normal code path.

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java

@ -170,7 +170,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
}
@Override
public ObjectReader newReader() {
public DfsReader newReader() {
return new DfsReader(this);
}

12
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java

@ -95,7 +95,7 @@ import org.eclipse.jgit.util.BlockList;
* See the base {@link ObjectReader} documentation for details. Notably, a
* reader is not thread safe.
*/
public final class DfsReader extends ObjectReader implements ObjectReuseAsIs {
public class DfsReader extends ObjectReader implements ObjectReuseAsIs {
private static final int MAX_RESOLVE_MATCHES = 256;
/** Temporary buffer large enough for at least one raw object id. */
@ -112,7 +112,13 @@ public final class DfsReader extends ObjectReader implements ObjectReuseAsIs {
private DfsPackFile last;
private boolean avoidUnreachable;
DfsReader(DfsObjDatabase db) {
/**
* Initialize a new DfsReader
*
* @param db
* parent DfsObjDatabase.
*/
protected DfsReader(DfsObjDatabase db) {
this.db = db;
this.streamFileThreshold = db.getReaderOptions().getStreamFileThreshold();
}
@ -129,7 +135,7 @@ public final class DfsReader extends ObjectReader implements ObjectReuseAsIs {
@Override
public ObjectReader newReader() {
return new DfsReader(db);
return db.newReader();
}
@Override

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java

@ -99,7 +99,7 @@ final class LargePackedWholeObject extends ObjectLoader {
@Override
public ObjectStream openStream() throws MissingObjectException, IOException {
DfsReader ctx = new DfsReader(db);
DfsReader ctx = db.newReader();
InputStream in;
try {
in = new PackInputStream(pack, objectOffset + headerLength, ctx);

Loading…
Cancel
Save