Fix memory leak
This commit is contained in:
parent
efe106b178
commit
ac5608c779
1 changed files with 10 additions and 2 deletions
|
|
@ -12,11 +12,19 @@ public interface Config extends ConfigSection {
|
||||||
void load(Reader reader);
|
void load(Reader reader);
|
||||||
|
|
||||||
default void load(InputStream stream) {
|
default void load(InputStream stream) {
|
||||||
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
|
||||||
|
load(reader);
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ConfigException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default void load(Path path) throws IOException, ConfigException {
|
default void load(Path path) throws IOException, ConfigException {
|
||||||
load(Files.newInputStream(path));
|
try (InputStream stream = Files.newInputStream(path)) {
|
||||||
|
load(stream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default void load(File file) throws IOException, ConfigException {
|
default void load(File file) throws IOException, ConfigException {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue