Bugfix: connection was closed, even when it was never created
authorKai Moritz <kai@coolibri.de>
Wed, 9 Jan 2013 19:57:22 +0000 (20:57 +0100)
committerKai Moritz <kai@coolibri.de>
Tue, 15 Jan 2013 20:41:04 +0000 (21:41 +0100)
Bugreport from: Adriano Machado <adriano.m.machado@hotmail.com>

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

index 81cef93..78793bb 100644 (file)
@@ -601,7 +601,8 @@ public class Hbm2DdlMojo extends AbstractMojo
       /** Close the connection */
       try
       {
-        connection.close();
+        if (connection != null)
+          connection.close();
       }
       catch (SQLException e)
       {