Skip to content

Commit 33231fe

Browse files
committed
Fix resource leak in nl.knaw.dans.lib.util.ZipUtil#extractZipFile
1 parent 3fa90c7 commit 33231fe

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/main/java/nl/knaw/dans/lib/util/ZipUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import java.io.BufferedOutputStream;
2424
import java.io.File;
25-
import java.io.FileOutputStream;
2625
import java.io.IOException;
2726
import java.io.InputStream;
2827
import java.io.OutputStream;
@@ -46,7 +45,9 @@ public static void extractZipFile(Path zipFilePath, Path outputDirectory) throws
4645
return;
4746
}
4847
Files.createDirectories(outputPath.getParent()); // ZIPs created by Dataverse don't seem to comply with the ZIP spec, so we have to create the parent directories manually
49-
IOUtils.copy(input, Files.newOutputStream(outputPath.toFile().toPath()));
48+
try (var os = Files.newOutputStream(outputPath)) {
49+
IOUtils.copyLarge(input, os);
50+
}
5051
}
5152
catch (IOException e) {
5253
throw new RuntimeException(e);

0 commit comments

Comments
 (0)