mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-09 12:20:36 +01:00
Closed some ConfigReaders appropriately
This commit is contained in:
parent
55e123f309
commit
6b7e9c1132
@ -152,7 +152,9 @@ public class SettingsTable extends Table {
|
||||
@Override
|
||||
public Config processResults(ResultSet set) throws SQLException {
|
||||
if (set.next()) {
|
||||
return new ConfigReader(new Scanner(set.getString(Col.CONFIG_CONTENT.get()))).read();
|
||||
try (ConfigReader reader = new ConfigReader(new Scanner(set.getString(Col.CONFIG_CONTENT.get())))) {
|
||||
return reader.read();
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public class ConfigReader implements Closeable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() {
|
||||
scanner.close();
|
||||
closed = true;
|
||||
}
|
||||
|
@ -185,8 +185,8 @@ public class NetworkSettingManager implements SubSystem {
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
try {
|
||||
Config config = new ConfigReader(file.toPath()).read();
|
||||
try (ConfigReader reader = new ConfigReader(file.toPath())) {
|
||||
Config config = reader.read();
|
||||
database.save().saveConfig(serverUUID, config);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
|
@ -105,8 +105,8 @@ public class ServerSettingsManager implements SubSystem {
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
try {
|
||||
Config config = new ConfigReader(file.toPath()).read();
|
||||
try (ConfigReader reader = new ConfigReader(file.toPath())) {
|
||||
Config config = reader.read();
|
||||
database.save().saveConfig(serverInfo.getServerUUID(), config);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
|
@ -26,8 +26,6 @@ import org.junit.runner.RunWith;
|
||||
import org.junitpioneer.jupiter.TempDirectory;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Scanner;
|
||||
|
||||
@ -50,8 +48,6 @@ class ConfigChangeTest {
|
||||
private Config prepareConfig(String withValue) {
|
||||
try (ConfigReader reader = new ConfigReader(new Scanner(withValue))) {
|
||||
return new Config(temporaryFolder.resolve("config.yml").toFile(), reader.read());
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user