Consistent use of try-with-resources for local resource closing

This commit is contained in:
Juergen Hoeller
2019-05-03 00:11:47 +02:00
parent 31c3b8a291
commit 5b1b1bae37
4 changed files with 22 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.jdbc.datasource.embedded;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
@@ -42,7 +43,9 @@ abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseCon
try {
con = dataSource.getConnection();
if (con != null) {
con.createStatement().execute("SHUTDOWN");
try (Statement stmt = con.createStatement()) {
stmt.execute("SHUTDOWN");
}
}
}
catch (SQLException ex) {