aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Borowitz2012-06-27 16:55:25 (EDT)
committerDave Borowitz2012-06-27 16:55:25 (EDT)
commitdc23a7cc421f09da42192c54ea8d54fb2ca30dfb (patch)
treecdb2505ff39eedccc973d39fb2b662d2a5ce5429
parent2d1124b89bbe739cf828c57a104a7b48e26c5db9 (diff)
downloadjgit-dc23a7cc421f09da42192c54ea8d54fb2ca30dfb.zip
jgit-dc23a7cc421f09da42192c54ea8d54fb2ca30dfb.tar.gz
jgit-dc23a7cc421f09da42192c54ea8d54fb2ca30dfb.tar.bz2
Make InMemoryRepository pack names globally uniquerefs/changes/32/6532/1
It was easy to create multiple packs with exactly the same name and same DfsRepositoryDescription in a test, which can poison the DfsBlockCache. The javadoc for DfsObjDatabase.newPack() explicitly says pack names should be unique within an entire DFS, so do this by making the packId AtomicInteger static. Arguably, test writers shouldn't be doing things like putting 'new DfsRepositoryDescription("test")' in a setUp() method, but that's a natural thing to do, and we don't document this restriction anywhere. Change-Id: I9477413ab3950d83b7d17e173fbc0a3e064896e3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java
index fb62ace..270f23f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java
@@ -26,6 +26,8 @@ import org.eclipse.jgit.util.RefList;
* is garbage collected. Closing the repository has no impact on its memory.
*/
public class InMemoryRepository extends DfsRepository {
+ private static final AtomicInteger packId = new AtomicInteger();
+
private final DfsObjDatabase objdb;
private final DfsRefDatabase refdb;
@@ -60,7 +62,6 @@ public class InMemoryRepository extends DfsRepository {
}
private class MemObjDatabase extends DfsObjDatabase {
- private final AtomicInteger packId = new AtomicInteger();
private List<DfsPackDescription> packs = new ArrayList<DfsPackDescription>();
MemObjDatabase(DfsRepository repo) {