DatabaseMetadata: NPE hides exception in finally block
There a is problem when an exception occurs in org.hibernate.tool.hbm2ddl.DatabaseMetadata#initSequences:
If rs = statement.executeQuery(sql) fails, then in finally block we try to invoke close() method on rs object, which is still null. According to JLS §14.20.2.:
If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and the throw of value V is discarded and forgotten).
So the reason why statement.executeQuery(sql) failed is discarded and forgotten and NullPointerException is thrown. That makes it really hard to debug.
I found this bug when I in my Spring application I've tried to connect do DERBY database using H2Dialect: