Skip to content

Commit 0a6a9c1

Browse files
committed
fix: mysql not throwing exception during failure to load towns
1 parent c53378b commit 0a6a9c1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

common/src/main/java/net/william278/husktowns/database/MySqlDatabase.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -370,16 +370,15 @@ public List<Town> getAllTowns() throws IllegalStateException {
370370
FROM `%town_data%`"""))) {
371371
final ResultSet resultSet = statement.executeQuery();
372372
while (resultSet.next()) {
373-
final String data = new String(resultSet.getBytes("data"), StandardCharsets.UTF_8);
374-
final Town town = plugin.getTownFromJson(data);
375-
if (town != null) {
376-
town.setId(resultSet.getInt("id"));
377-
towns.add(town);
378-
}
373+
final Town town = plugin.getTownFromJson(
374+
new String(resultSet.getBytes("data"), StandardCharsets.UTF_8)
375+
);
376+
town.setId(resultSet.getInt("id"));
377+
towns.add(town);
379378
}
380379
}
381380
} catch (SQLException | JsonSyntaxException e) {
382-
plugin.log(Level.SEVERE, "Failed to fetch all town data from table", e);
381+
throw new IllegalStateException("Failed to fetch all town data from table", e);
383382
}
384383
return towns;
385384
}

0 commit comments

Comments
 (0)