Skip to content

Commit 40b04cb

Browse files
committed
Fix cache_upgraded_structures leaking open input streams
1 parent b1e9168 commit 40b04cb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/cache_upgraded_structures/StructureManagerMixin.java

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

1515
import java.io.FileNotFoundException;
1616
import java.io.IOException;
17+
import java.io.InputStream;
1718
import java.util.Optional;
1819

1920
@Mixin(StructureTemplateManager.class)
@@ -29,8 +30,8 @@ public class StructureManagerMixin {
2930
@Overwrite
3031
private Optional<StructureTemplate> loadFromResource(ResourceLocation id) {
3132
ResourceLocation arg = new ResourceLocation(id.getNamespace(), "structures/" + id.getPath() + ".nbt");
32-
try {
33-
return Optional.of(CachingStructureManager.readStructure(id, this.fixerUpper, this.resourceManager.open(arg)));
33+
try(InputStream stream = this.resourceManager.open(arg)) {
34+
return Optional.of(CachingStructureManager.readStructure(id, this.fixerUpper, stream));
3435
} catch(FileNotFoundException e) {
3536
return Optional.empty();
3637
} catch(IOException e) {

0 commit comments

Comments
 (0)