aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGlease <4586901+Glease@users.noreply.github.com>2022-09-09 16:39:17 +0800
committerGitHub <noreply@github.com>2022-09-09 16:39:17 +0800
commitc7f9ac2f9300278d829524b16f893bd775cfda24 (patch)
tree1b85547c3d92edd31ea478ee80ff99a38b6325e4 /src/main
parentf4d09726e6e880120f9e68edd259914bca9cd494 (diff)
downloadGT5-Unofficial-c7f9ac2f9300278d829524b16f893bd775cfda24.tar.gz
GT5-Unofficial-c7f9ac2f9300278d829524b16f893bd775cfda24.tar.bz2
GT5-Unofficial-c7f9ac2f9300278d829524b16f893bd775cfda24.zip
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>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java10
1 files changed, 5 insertions, 5 deletions
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<T extends GT_ChunkAssociatedData.ID
if (!getSaveDirectory(w).isDirectory())
// nothing to load...
return;
- try {
- Map<ChunkCoordIntPair, SuperRegion> worldData = Files.list(
- getSaveDirectory(w).toPath())
- .map(f -> {
+ try (Stream<Path> stream = Files.list(getSaveDirectory(w).toPath())) {
+ Map<ChunkCoordIntPair, SuperRegion> 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<T extends GT_ChunkAssociatedData.ID
.filter(Objects::nonNull)
.collect(Collectors.toMap(SuperRegion::getCoord, Function.identity()));
masterMap.put(w.provider.dimensionId, worldData);
- } catch (IOException e) {
+ } catch (IOException | UncheckedIOException e) {
GT_Log.err.println("Error loading all region");
e.printStackTrace(GT_Log.err);
}