From c7f9ac2f9300278d829524b16f893bd775cfda24 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 9 Sep 2022 16:39:17 +0800 Subject: Close the directory stream as specified by javadoc (#1360) Co-authored-by: Glease <4586901+Glease@users.noreply.github.com> Co-authored-by: GitHub GTNH Actions <> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java index 38b147e318..ac04ecfd46 100644 --- a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java +++ b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java @@ -11,10 +11,12 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.UncheckedIOException; import java.lang.ref.WeakReference; import java.lang.reflect.Array; import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.Arrays; import java.util.Map; @@ -218,10 +220,8 @@ public abstract class GT_ChunkAssociatedData worldData = Files.list( - getSaveDirectory(w).toPath()) - .map(f -> { + try (Stream stream = Files.list(getSaveDirectory(w).toPath())) { + Map worldData = stream.map(f -> { Matcher matcher = FILE_PATTERN.matcher(f.getFileName().toString()); return matcher.matches() ? matcher : null; }) @@ -242,7 +242,7 @@ public abstract class GT_ChunkAssociatedData