diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2014-12-22 11:19:22 +0100 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2014-12-22 15:19:09 +0100 |
commit | 3226e35db846bbb848c3fe62e3e435fae52a2d5b (patch) | |
tree | e246deb0627934e920003e3da91ed128f7d8fb6b /org.eclipse.jgit | |
parent | d49c9ee84840f76604242b1ddf6cd5e6b898bdfa (diff) | |
download | jgit-3226e35db846bbb848c3fe62e3e435fae52a2d5b.tar.gz jgit-3226e35db846bbb848c3fe62e3e435fae52a2d5b.zip |
Fix junit tests under windows when the platform is explicitly changed
SystemReader used a chached ObjectChecker which was instantiated only
once. But in case of unit tests where we can change the platform
dynamically (e.g. MockSystemReader.setWindows()) this is wrong and
caused DirCacheCheckoutMaliciousPathTest.
testMaliciousAbsoluteCurDrivePathWindowsOnUnix() to fail. This change
allows
user of SystemReader to force the creation of a new ObjectChecker.
MockSystemReader.setWindows() and .setUnix() make use of this feature.
Change-Id: I87458d1dc63c1f5c18979f972b1c1f0d670a9ed8
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java index 3447f639d4..f6f415e85b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java @@ -163,11 +163,19 @@ public abstract class SystemReader { private void init() { // Creating ObjectChecker must be deferred. Unit tests change // behavior of is{Windows,MacOS} in constructor of subclass. - if (platformChecker == null) { - platformChecker = new ObjectChecker() - .setSafeForWindows(isWindows()) - .setSafeForMacOS(isMacOS()); - } + if (platformChecker == null) + setPlatformChecker(); + } + + /** + * Should be used in tests when the platform is explicitly changed. + * + * @since 3.6 + */ + protected final void setPlatformChecker() { + platformChecker = new ObjectChecker() + .setSafeForWindows(isWindows()) + .setSafeForMacOS(isMacOS()); } /** |