aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2017-12-07 16:30:01 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2017-12-07 20:02:59 +0900
commit61790cb931d8b5f932f160ebe80bb8cabe248a75 (patch)
treed2a4c36a3e8bcf603457c8e9ecd3783c4aaeaa61 /org.eclipse.jgit/src
parent171f84a04117cfd02446f67565073a05128777a4 (diff)
downloadjgit-61790cb931d8b5f932f160ebe80bb8cabe248a75.tar.gz
jgit-61790cb931d8b5f932f160ebe80bb8cabe248a75.zip
FS_POSIX: Fix boxing/unboxing of Boolean
Boolean is being abused to represent three possible states of atomic file creation support (true/enabled, false/disabled, null/undefined). Replace this with an enum of the three explicit states. Change-Id: I2cd7fa6422311dc427823304b082ce8da50d2fbe Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
index 05db583b41..969afd2a97 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
@@ -80,7 +80,11 @@ public class FS_POSIX extends FS {
private volatile boolean supportsUnixNLink = true;
- private volatile Boolean supportsAtomicCreateNewFile;
+ private volatile AtomicFileCreation supportsAtomicCreateNewFile = AtomicFileCreation.UNDEFINED;
+
+ private enum AtomicFileCreation {
+ SUPPORTED, NOT_SUPPORTED, UNDEFINED
+ }
/** Default constructor. */
protected FS_POSIX() {
@@ -99,31 +103,34 @@ public class FS_POSIX extends FS {
}
}
- @SuppressWarnings("boxing")
private void determineAtomicFileCreationSupport() {
// @TODO: enhance SystemReader to support this without copying code
- Boolean ret = getAtomicFileCreationSupportOption(
+ AtomicFileCreation ret = getAtomicFileCreationSupportOption(
SystemReader.getInstance().openUserConfig(null, this));
- if (ret == null && StringUtils.isEmptyOrNull(SystemReader.getInstance()
- .getenv(Constants.GIT_CONFIG_NOSYSTEM_KEY))) {
+ if (ret == AtomicFileCreation.UNDEFINED
+ && StringUtils.isEmptyOrNull(SystemReader.getInstance()
+ .getenv(Constants.GIT_CONFIG_NOSYSTEM_KEY))) {
ret = getAtomicFileCreationSupportOption(
SystemReader.getInstance().openSystemConfig(null, this));
}
- supportsAtomicCreateNewFile = (ret == null) || ret;
+ supportsAtomicCreateNewFile = ret;
}
- private Boolean getAtomicFileCreationSupportOption(FileBasedConfig config) {
+ private AtomicFileCreation getAtomicFileCreationSupportOption(
+ FileBasedConfig config) {
try {
config.load();
String value = config.getString(ConfigConstants.CONFIG_CORE_SECTION,
null,
ConfigConstants.CONFIG_KEY_SUPPORTSATOMICFILECREATION);
if (value == null) {
- return null;
+ return AtomicFileCreation.UNDEFINED;
}
- return Boolean.valueOf(StringUtils.toBoolean(value));
+ return StringUtils.toBoolean(value)
+ ? AtomicFileCreation.SUPPORTED
+ : AtomicFileCreation.NOT_SUPPORTED;
} catch (IOException | ConfigInvalidException e) {
- return Boolean.TRUE;
+ return AtomicFileCreation.SUPPORTED;
}
}
@@ -340,10 +347,10 @@ public class FS_POSIX extends FS {
@Override
public boolean supportsAtomicCreateNewFile() {
- if (supportsAtomicCreateNewFile == null) {
+ if (supportsAtomicCreateNewFile == AtomicFileCreation.UNDEFINED) {
determineAtomicFileCreationSupport();
}
- return supportsAtomicCreateNewFile.booleanValue();
+ return supportsAtomicCreateNewFile == AtomicFileCreation.SUPPORTED;
}
@Override