diff options
author | ccalvarin <ccalvarin@google.com> | 2018-07-26 14:38:51 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-26 14:40:16 -0700 |
commit | 7e87730de985b7099b9b683571d58efdaab70890 (patch) | |
tree | 42f4bba0c0f6d99455a68fc6beead8d2edb8fc08 /src/main/java/com/google/devtools/build/lib/vfs | |
parent | 0ccfde8b8bb646166a4f45c8630e8fe174f764f4 (diff) |
Remove default MD5 in most of Bazel's virtual filesystems.
This forces the ex-default to be explicit in a lot of tests, but I'd rather that than have the risk of implicit md5-use in production code.
To keep this CL smaller, do not remove the default from UnixFS quite yet.
RELNOTES: None.
PiperOrigin-RevId: 206223521
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs')
7 files changed, 20 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java index 096ca500f4..a5a454c687 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java @@ -30,8 +30,6 @@ public abstract class AbstractFileSystem extends FileSystem { protected static final String ERR_PERMISSION_DENIED = " (Permission denied)"; protected static final Profiler profiler = Profiler.instance(); - public AbstractFileSystem() {} - public AbstractFileSystem(DigestHashFunction digestFunction) { super(digestFunction); } diff --git a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystemWithCustomStat.java b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystemWithCustomStat.java index 2a2b06b50a..2891f12126 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystemWithCustomStat.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystemWithCustomStat.java @@ -22,8 +22,6 @@ import java.io.IOException; */ public abstract class AbstractFileSystemWithCustomStat extends AbstractFileSystem { - public AbstractFileSystemWithCustomStat() {} - public AbstractFileSystemWithCustomStat(DigestHashFunction hashFunction) { super(hashFunction); } diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java index 8d10e5800b..63cf2823f1 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java @@ -38,10 +38,6 @@ public abstract class FileSystem { private final DigestHashFunction digestFunction; - public FileSystem() { - this(DigestHashFunction.MD5); - } - public FileSystem(DigestHashFunction digestFunction) { this.digestFunction = Preconditions.checkNotNull(digestFunction); } diff --git a/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java index 1fec03f5db..00a320fa57 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java @@ -53,7 +53,7 @@ public class JavaIoFileSystem extends AbstractFileSystemWithCustomStat { protected static final String ERR_NOT_A_DIRECTORY = " (Not a directory)"; public JavaIoFileSystem() { - this(new JavaClock()); + this(new JavaClock(), DigestHashFunction.MD5); } public JavaIoFileSystem(DigestHashFunction hashFunction) { @@ -62,7 +62,8 @@ public class JavaIoFileSystem extends AbstractFileSystemWithCustomStat { } @VisibleForTesting - JavaIoFileSystem(Clock clock) { + JavaIoFileSystem(Clock clock, DigestHashFunction hashFunction) { + super(hashFunction); this.clock = clock; } diff --git a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java index 938f7a7ffb..f52c786aa7 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java @@ -36,7 +36,8 @@ import java.io.OutputStream; */ public abstract class ReadonlyFileSystem extends AbstractFileSystem { - protected ReadonlyFileSystem() { + protected ReadonlyFileSystem(DigestHashFunction hashFunction) { + super(hashFunction); } protected IOException modificationException() { diff --git a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java index f9ca4ebb87..7ef4a093ab 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java @@ -20,7 +20,9 @@ import java.io.OutputStream; * Functionally like a {@link ReadonlyFileSystem} and a {@link AbstractFileSystemWithCustomStat}. */ public abstract class ReadonlyFileSystemWithCustomStat extends AbstractFileSystemWithCustomStat { - protected ReadonlyFileSystemWithCustomStat() { + + protected ReadonlyFileSystemWithCustomStat(DigestHashFunction hashFunction) { + super(hashFunction); } protected IOException modificationException() { diff --git a/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java index f24a3d99a8..a83d6ab047 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.vfs.inmemoryfs; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.devtools.build.lib.clock.Clock; @@ -58,20 +59,20 @@ public class InMemoryFileSystem extends FileSystem { // Maximum number of traversals before ELOOP is thrown. private static final int MAX_TRAVERSALS = 256; - /** - * Creates a new InMemoryFileSystem with scope checking disabled (all paths are considered to be - * within scope) and a default clock. - */ + // TODO(b/109764197): Remove the no-arg constructor from Jadep and then remove it here. + @VisibleForTesting public InMemoryFileSystem() { - this(new JavaClock()); + this(new JavaClock(), DigestHashFunction.MD5); } /** - * Creates a new InMemoryFileSystem with scope checking disabled (all - * paths are considered to be within scope). + * Creates a new InMemoryFileSystem with scope checking disabled (all paths are considered to be + * within scope) and a default clock. + * + * @param hashFunction */ - public InMemoryFileSystem(Clock clock) { - this(clock, (PathFragment) null); + public InMemoryFileSystem(DigestHashFunction hashFunction) { + this(new JavaClock(), hashFunction); } /** @@ -89,7 +90,8 @@ public class InMemoryFileSystem extends FileSystem { * Creates a new InMemoryFileSystem with scope checking bound to scopeRoot, i.e. any path that's * not below scopeRoot is considered to be out of scope. */ - public InMemoryFileSystem(Clock clock, PathFragment scopeRoot) { + public InMemoryFileSystem(Clock clock, PathFragment scopeRoot, DigestHashFunction hashFunction) { + super(hashFunction); this.scopeRoot = scopeRoot; this.clock = clock; this.rootInode = newRootInode(clock); |