You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/06/27 15:23:21 UTC
[commons-vfs] 03/06: Fix compiler warnings.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
commit a5c09f53a4c31b7f4e30ab6f775163895156ff55
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 26 10:59:16 2019 -0400
Fix compiler warnings.
---
.../apache/commons/vfs2/filter/EmptyFileFilter.java | 21 +++++++++++----------
.../apache/commons/vfs2/filter/SizeFileFilter.java | 3 ++-
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java
index a36a7a1..bc5cdaa 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java
@@ -86,16 +86,17 @@ public class EmptyFileFilter implements FileFilter, Serializable {
*/
@Override
public boolean accept(final FileSelectInfo fileInfo) throws FileSystemException {
- final FileObject file = fileInfo.getFile();
- if (!file.exists()) {
- return true;
- }
- if (file.getType() == FileType.FOLDER) {
- final FileObject[] files = file.getChildren();
- return files == null || files.length == 0;
- }
- try (final FileContent content = file.getContent();) {
- return content.getSize() == 0;
+ try (final FileObject file = fileInfo.getFile()) {
+ if (!file.exists()) {
+ return true;
+ }
+ if (file.getType() == FileType.FOLDER) {
+ final FileObject[] files = file.getChildren();
+ return files == null || files.length == 0;
+ }
+ try (final FileContent content = file.getContent();) {
+ return content.getSize() == 0;
+ }
}
}
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 aa587bd..f9fcccf 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
@@ -100,7 +100,7 @@ public class SizeFileFilter implements FileFilter, Serializable {
*/
@Override
public boolean accept(final FileSelectInfo fileInfo) throws FileSystemException {
- final FileObject file = fileInfo.getFile();
+ try (final FileObject file = fileInfo.getFile()) {
if (!file.exists()) {
return false;
}
@@ -109,6 +109,7 @@ public class SizeFileFilter implements FileFilter, Serializable {
final boolean smaller = length < size;
return acceptLarger ? !smaller : smaller;
}
+ }
}
/**