diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 3ba026d797..9d10636dec 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -127,6 +127,7 @@ import static hudson.FilePath.TarCompression.GZIP; import static hudson.Util.deleteFile; import static hudson.Util.fixEmpty; import static hudson.Util.isSymlink; +import java.util.Collections; /** * {@link File} like object with remoting support. @@ -1636,6 +1637,7 @@ public final class FilePath implements Serializable { *

* This method returns direct children of the directory denoted by the 'this' object. */ + @Nonnull public List list() throws IOException, InterruptedException { return list((FileFilter)null); } @@ -1645,6 +1647,7 @@ public final class FilePath implements Serializable { * * @return can be empty but never null. Doesn't contain "." and ".." */ + @Nonnull public List listDirectories() throws IOException, InterruptedException { return list(new DirectoryFilter()); } @@ -1665,6 +1668,7 @@ public final class FilePath implements Serializable { * If this {@link FilePath} represents a remote path, * the filter object will be executed on the remote machine. */ + @Nonnull public List list(final FileFilter filter) throws IOException, InterruptedException { if (filter != null && !(filter instanceof Serializable)) { throw new IllegalArgumentException("Non-serializable filter of " + filter.getClass()); @@ -1673,7 +1677,9 @@ public final class FilePath implements Serializable { private static final long serialVersionUID = 1L; public List invoke(File f, VirtualChannel channel) throws IOException { File[] children = reading(f).listFiles(filter); - if(children ==null) return null; + if (children == null) { + return Collections.emptyList(); + } ArrayList r = new ArrayList(children.length); for (File child : children) @@ -1692,6 +1698,7 @@ public final class FilePath implements Serializable { * @return * can be empty but always non-null. */ + @Nonnull public FilePath[] list(final String includes) throws IOException, InterruptedException { return list(includes, null); } @@ -1706,6 +1713,7 @@ public final class FilePath implements Serializable { * can be empty but always non-null. * @since 1.407 */ + @Nonnull public FilePath[] list(final String includes, final String excludes) throws IOException, InterruptedException { return list(includes, excludes, true); } @@ -1721,6 +1729,7 @@ public final class FilePath implements Serializable { * can be empty but always non-null. * @since 1.465 */ + @Nonnull public FilePath[] list(final String includes, final String excludes, final boolean defaultExcludes) throws IOException, InterruptedException { return act(new SecureFileCallable() { private static final long serialVersionUID = 1L; @@ -1742,6 +1751,7 @@ public final class FilePath implements Serializable { * @return * A set of relative file names from the base directory. */ + @Nonnull private static String[] glob(File dir, String includes, String excludes, boolean defaultExcludes) throws IOException { if(isAbsolute(includes)) throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax"); diff --git a/core/src/main/java/jenkins/util/VirtualFile.java b/core/src/main/java/jenkins/util/VirtualFile.java index 6c70fedcea..e2d27d75ec 100644 --- a/core/src/main/java/jenkins/util/VirtualFile.java +++ b/core/src/main/java/jenkins/util/VirtualFile.java @@ -365,9 +365,6 @@ public abstract class VirtualFile implements Comparable, Serializab @Override public VirtualFile[] list() throws IOException { try { List kids = f.list(); - if (kids == null) { - return new VirtualFile[0]; - } VirtualFile[] vfs = new VirtualFile[kids.size()]; for (int i = 0; i < vfs.length; i++) { vfs[i] = forFilePath(kids.get(i));