Skip to content

Commit e443d4c

Browse files
Merge pull request #89 from A5H73Y/master
2 parents 76ddf0a + 1f7e091 commit e443d4c

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<skip>true</skip>
120120
</configuration>
121121
<groupId>org.apache.maven.plugins</groupId>
122-
<version>3.0.0-M1</version>
122+
<version>3.1.4</version>
123123
</plugin>
124124

125125
<plugin>
@@ -157,7 +157,7 @@
157157
<artifactId>json</artifactId>
158158
<groupId>org.json</groupId>
159159
<scope>compile</scope>
160-
<version>20231013</version>
160+
<version>20251224</version>
161161
</dependency>
162162

163163
<!-- Lombok -->

src/main/java/de/leonhard/storage/Json.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ protected final Map<String, Object> readToMap() throws IOException {
106106
Files.write(this.file.toPath(), Collections.singletonList("{}"));
107107
}
108108

109-
val jsonTokener = new JSONTokener(FileUtils.createInputStream(this.file));
110-
return new JSONObject(jsonTokener).toMap();
109+
try (InputStream in = FileUtils.createInputStream(this.file)) {
110+
return new JSONObject(new JSONTokener(in)).toMap();
111+
}
111112
}
112113

113114
@Override

src/main/java/de/leonhard/storage/internal/editor/toml/TomlManager.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public String writeToString(final Map<String, Object> data) throws IOException {
5555
* @throws IOException if an error occurs
5656
*/
5757
public void write(final Map<String, Object> data, final File file) throws IOException {
58-
final FileOutputStream out = new FileOutputStream(file);
59-
write(data, out);
58+
try (FileOutputStream out = new FileOutputStream(file)) {
59+
write(data, out);
60+
}
6061
}
6162

6263
/**
@@ -160,7 +161,9 @@ public Map<String, Object> read(final File file) throws IOException, TomlExcepti
160161
*/
161162
public Map<String, Object> read(final File file, final boolean strictAsciiBareKeys)
162163
throws IOException, TomlException {
163-
return read(Files.newInputStream(file.toPath()), strictAsciiBareKeys);
164+
try (InputStream in = Files.newInputStream(file.toPath())) {
165+
return read(in, strictAsciiBareKeys);
166+
}
164167
}
165168

166169
/**

0 commit comments

Comments
 (0)