From 798744838c6cc96c5989cc6ed5944e7dfe8f2cc3 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 13 Jan 2020 12:51:31 +0100 Subject: [PATCH] Revise exception handling in AbstractEmbeddedDatabaseConfigurer See gh-24337 --- .../AbstractEmbeddedDatabaseConfigurer.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java index 82816ba95392..05a8321ca7f3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,6 +25,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.jdbc.support.JdbcUtils; + /** * Base class for {@link EmbeddedDatabaseConfigurer} implementations * providing common shutdown behavior through a "SHUTDOWN" statement. @@ -53,14 +55,7 @@ public void shutdown(DataSource dataSource, String databaseName) { logger.info("Could not shut down embedded database", ex); } finally { - if (con != null) { - try { - con.close(); - } - catch (Throwable ex) { - logger.debug("Could not close JDBC Connection on shutdown", ex); - } - } + JdbcUtils.closeConnection(con); } }