Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-vfs
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java
index c8d3ef4..b430ea9 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java
@@ -171,15 +171,9 @@
final int hash = Arrays.deepHashCode(myOptions.values().toArray());
final int hashFk = Arrays.deepHashCode(theirOptions.values().toArray());
- if (hash < hashFk) {
- return -1;
- }
- if (hash > hashFk) {
- return 1;
- }
+ return Integer.compare(hash, hashFk);
// TODO: compare Entry by Entry ??
- return 0;
}
@Override
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
index 1b835a9..76b8ae9 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
@@ -100,7 +100,7 @@
}
final Map<?, ?> files = filesystemCache.get(filesystem);
- if (files.size() < 1) {
+ if (files.isEmpty()) {
filesystemCache.remove(filesystem);
}
@@ -208,7 +208,7 @@
try {
files.remove(name);
- if (files.size() < 1) {
+ if (files.isEmpty()) {
filesystemCache.remove(filesystem);
}
} finally {
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/SoftRefFilesCache.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/SoftRefFilesCache.java
index 05b43a8..8243380 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/SoftRefFilesCache.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/SoftRefFilesCache.java
@@ -223,7 +223,7 @@
}
}
- if (files.size() < 1) {
+ if (files.isEmpty()) {
close(fileSystem);
}
} finally {
@@ -288,7 +288,7 @@
refReverseMap.remove(ref);
}
- return files.size() < 1;
+ return files.isEmpty();
} finally {
lock.unlock();
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java
index cafe014..9a552f2 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java
@@ -176,7 +176,7 @@
@Override
public boolean accept(final FileSelectInfo fileInfo) throws FileSystemException {
final boolean newer = isFileNewer(fileInfo.getFile(), cutoff);
- return acceptOlder ? !newer : newer;
+ return acceptOlder != newer;
}
/**
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java
index ede1025..f0f1140 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java
@@ -107,7 +107,7 @@
try (final FileContent content = file.getContent()) {
final long length = content.getSize();
final boolean smaller = length < size;
- return acceptLarger ? !smaller : smaller;
+ return acceptLarger != smaller;
}
}
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
index 494a120..1575149 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
@@ -1521,7 +1521,7 @@
@Override
public boolean isExecutable() throws FileSystemException {
try {
- return exists() ? doIsExecutable() : false;
+ return exists() && doIsExecutable();
} catch (final Exception exc) {
throw new FileSystemException("vfs.provider/check-is-executable.error", fileName, exc);
}
@@ -1564,7 +1564,7 @@
@Override
public boolean isHidden() throws FileSystemException {
try {
- return exists() ? doIsHidden() : false;
+ return exists() && doIsHidden();
} catch (final Exception exc) {
throw new FileSystemException("vfs.provider/check-is-hidden.error", fileName, exc);
}
@@ -1579,7 +1579,7 @@
@Override
public boolean isReadable() throws FileSystemException {
try {
- return exists() ? doIsReadable() : false;
+ return exists() && doIsReadable();
} catch (final Exception exc) {
throw new FileSystemException("vfs.provider/check-is-readable.error", fileName, exc);
}
@@ -1608,7 +1608,7 @@
@Override
public boolean isSymbolicLink() throws FileSystemException {
try {
- return exists() ? doIsSymbolicLink() : false;
+ return exists() && doIsSymbolicLink();
} catch (final Exception exc) {
throw new FileSystemException("vfs.provider/check-is-symbolic-link.error", fileName, exc);
}
@@ -1847,7 +1847,7 @@
@Override
public boolean setExecutable(final boolean readable, final boolean ownerOnly) throws FileSystemException {
try {
- return exists() ? doSetExecutable(readable, ownerOnly) : false;
+ return exists() && doSetExecutable(readable, ownerOnly);
} catch (final Exception exc) {
throw new FileSystemException("vfs.provider/set-executable.error", fileName, exc);
}
@@ -1867,7 +1867,7 @@
@Override
public boolean setReadable(final boolean readable, final boolean ownerOnly) throws FileSystemException {
try {
- return exists() ? doSetReadable(readable, ownerOnly) : false;
+ return exists() && doSetReadable(readable, ownerOnly);
} catch (final Exception exc) {
throw new FileSystemException("vfs.provider/set-readable.error", fileName, exc);
}
@@ -1878,7 +1878,7 @@
@Override
public boolean setWritable(final boolean readable, final boolean ownerOnly) throws FileSystemException {
try {
- return exists() ? doSetWritable(readable, ownerOnly) : false;
+ return exists() && doSetWritable(readable, ownerOnly);
} catch (final Exception exc) {
throw new FileSystemException("vfs.provider/set-writeable.error", fileName, exc);
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java
index 9faf1af..92c80be 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java
@@ -230,6 +230,7 @@
for (int i = 0; !match && i < reserved.length; i++) {
if (ch == reserved[i]) {
match = true;
+ break;
}
}
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java
index a27fc07..50ef2ed 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java
@@ -242,7 +242,7 @@
}
}
}
- final boolean isOwner = checkIds ? attrs.getUId() == getAbstractFileSystem().getUId() : false;
+ final boolean isOwner = checkIds && attrs.getUId() == getAbstractFileSystem().getUId();
return new PosixPermissions(attrs.getPermissions(), isOwner, isInGroup);
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/temp/TemporaryFileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/temp/TemporaryFileProvider.java
index a9c8364..a057527 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/temp/TemporaryFileProvider.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/temp/TemporaryFileProvider.java
@@ -57,14 +57,8 @@
public int compareTo(final Object o) {
final int h1 = hashCode();
final int h2 = o.hashCode();
- if (h1 < h2) {
- return -1;
- }
- if (h1 > h2) {
- return 1;
- }
+ return Integer.compare(h1, h2);
- return 0;
}
/**