Fix resource leak

- Fix ponder resources not being closed properly
This commit is contained in:
PepperBell 2021-07-22 16:13:03 -07:00
parent 37261ee8e6
commit 8f6dcb8ba6

View file

@ -2,6 +2,7 @@ package com.simibubi.create.foundation.ponder;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -140,15 +141,12 @@ public class PonderRegistry {
String path = "ponder/" + location.getPath() + ".nbt"; String path = "ponder/" + location.getPath() + ".nbt";
ResourceLocation location1 = new ResourceLocation(namespace, path); ResourceLocation location1 = new ResourceLocation(namespace, path);
if (!resourceManager.hasResource(location1)) { try (IResource resource = resourceManager.getResource(location1)) {
Create.LOGGER.error("Ponder schematic missing: " + location1);
return new Template();
}
try {
IResource resource = resourceManager.getResource(location1);
return loadSchematic(resource.getInputStream()); return loadSchematic(resource.getInputStream());
} catch (FileNotFoundException e) {
Create.LOGGER.error("Ponder schematic missing: " + location1, e);
} catch (IOException e) { } catch (IOException e) {
Create.LOGGER.error("Failed to read ponder schematic: " + path, e); Create.LOGGER.error("Failed to read ponder schematic: " + location1, e);
} }
return new Template(); return new Template();
} }