Skip to content

Commit

Permalink
Fix CodeQL code scanning alert in ApplicationErrorJdbcTest
Browse files Browse the repository at this point in the history
Even though it's a test, better to do it correctly and ensure
the Statement and ResultSet are closed using try-with-resources
  • Loading branch information
sleberknight committed Nov 25, 2023
1 parent 56bc67a commit a568cb2
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,13 @@ void shouldMigrate_H2InMemoryDatabase() throws SQLException {

ApplicationErrorJdbc.migrateDatabase(conn);

var stmt = conn.createStatement();
var rs = stmt.executeQuery("select * from databasechangelog");
nextOrThrow(rs);
try (var stmt = conn.createStatement()) {
var rs = stmt.executeQuery("select * from databasechangelog");
nextOrThrow(rs);

var filename = rs.getString("filename");
assertThat(filename).isEqualTo("dropwizard-app-errors-migrations.xml");
var filename = rs.getString("filename");
assertThat(filename).isEqualTo("dropwizard-app-errors-migrations.xml");
}
}
}

Expand Down

0 comments on commit a568cb2

Please sign in to comment.