java - Infinite loop while using Files.newDirectoryStream -
i wrote test zip files in dummy directory:
public void compressfiletoziptest() throws ioexception{ try (directorystream<path> stream = files.newdirectorystream( paths.get("src", "test", "resources", "dummy", "files"), new filesfilter())){ (path entry: stream) { path dst = entry.getparent().resolve(entry.getfilename().tostring() + ".zip"); boolean succeed = filesutility.compresstozip(entry, dst); assert.asserttrue("failed create destination file", succeed); try(zipfile zipfile = new zipfile(dst.tofile())){ assert.asserttrue("failed compress file size", files.size(entry) > files.size(dst)); } dst.tofile().deleteonexit(); } } } private static final class filesfilter implements directorystream.filter<path>{ @override public boolean accept(path entry) throws ioexception { return !files.isdirectory(entry); } }
the test worked until our build team changed underlining nas storage, lead infinite loop while streaming directory , writing it.
i glad if 1 can explain issue (i assume it's related paths iterator implementation).
Comments
Post a Comment