いくつかのダミー ディレクトリに zip ファイルを作成するテストを作成しました。
public void compressFileToZipTest() throws IOException{
try (DirectoryStream<Path> stream = Files.newDirectoryStream(
Paths.get("src", "test", "resources", "dummy", "files"), new FilesFilter())){
for (Path entry: stream) {
Path dst = entry.getParent().resolve(entry.getFileName().toString() + ".zip");
boolean succeed = FilesUtility.compressToZip(entry, dst);
Assert.assertTrue("Failed to create destination file", succeed);
try(ZipFile zipFile = new ZipFile(dst.toFile())){
Assert.assertTrue("Failed to 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);
}
}
ビルド チームが下線を引く NAS ストレージを変更するまで、テストはうまく機能しました。これにより、ディレクトリからのストリーミングと書き込み中に無限ループが発生しました。
誰かが問題を説明できれば幸いです(パスイテレータの実装に関連していると思います)。