Bad finally block in SpringLiquibase.afterPropertiesSet()

Description

At the end of the SpringLiquibase.afterPropertiesSet() method, the finally block does not check if the liquibase instance is null or not (as it is null before entering the try block, it could be null on exit). In my case, I have an error occurring in the 2 first lines of the try block (and my liquibase instance is never assigned) and this error is shadowed by a NPE on the first line of the finally block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Connection c = null; Liquibase liquibase = null; try { c = getDataSource().getConnection(); liquibase = createLiquibase(c); generateRollbackFile(liquibase); performUpdate(liquibase); } catch (SQLException e) { throw new DatabaseException(e); } finally { Database database = liquibase.getDatabase(); if (database != null) { database.close(); } }

Environment

windows, maven, cargo

Status

Assignee

Unassigned

Reporter

Xavier Dury

Labels

None

Fix versions

Affects versions

3.3.0

Priority

Critical