From: Kai Moritz Date: Wed, 9 Jan 2013 19:57:22 +0000 (+0100) Subject: Bugfix: connection was closed, even when it was never created X-Git-Tag: hibernate4-maven-plugin-1.0.1~9 X-Git-Url: http://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=commitdiff_plain;h=54b22b88de40795a73397ac8b3725716bc80b6c4;hp=b9ab24b21d3eb65e2a2208be658ff447c1846894;ds=sidebyside 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. --- 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) {