From 54b22b88de40795a73397ac8b3725716bc80b6c4 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 9 Jan 2013 20:57:22 +0100 Subject: [PATCH] Bugfix: connection was closed, even when it was never created Bugreport from: Adriano Machado When only the script is generated and no export is executed, no database- connection is opend. Nevertheless, the code tried to close it in the finally-block, which lead to a NPE. --- src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index 81cef938..78793bb5 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -601,7 +601,8 @@ public class Hbm2DdlMojo extends AbstractMojo /** Close the connection */ try { - connection.close(); + if (connection != null) + connection.close(); } catch (SQLException e) { -- 2.20.1