aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2017-05-19 13:47:10 -0700
committerShawn Pearce <spearce@spearce.org>2017-05-19 13:50:36 -0700
commit1513a5632dcaf8c6e2d6998427087e11ba35566d (patch)
tree8afa658c6870fa5b6c30c2cf9abfb9b4eb738422
parent562de51239a24440c495eaae157b881af5cac2c7 (diff)
downloadjgit-1513a5632dcaf8c6e2d6998427087e11ba35566d.tar.gz
jgit-1513a5632dcaf8c6e2d6998427087e11ba35566d.zip
Allow DfsReader to be subclassed
Necessary if a DFS implementation wants to override close() to record DfsReaderIoStats. Change-Id: I144575f9bf1abf2c1fd72030550c4f0795fcf44d
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java2
5 files changed, 14 insertions, 8 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java
index 32002fd01d..17c1835bd0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java
+++ b/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);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
index fd72756e39..e65c9fda7a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
+++ b/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.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
index b1cb72dec9..32ee6c288e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
+++ b/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);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
index d4e7e86ccb..d611469afc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
+++ b/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
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java
index 6d40a7505e..73a93e6575 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java
+++ b/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);