Execution of Liquibase in Java hangs … and solution. Patch needed


I had a problem executing Liquibase 4.27.0 from Java which took me several days to find a solution. I am not sure if it is a bug in Liquibase or just the special execution environment but at least it is an inconsistency in Liquibase which in my opinion is not very nice.

I execute the Japedo Maven plugin on a project in my Eclipse environment on Windows. The plugin starts the Japedo tool to generate java persistence and database documentation. Japedo starts a thread to setup an in-memory database from Liquibase changesets and analyze the database afterwards. Liquibase is executed with

Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
Liquibase liq = new Liquibase(liqPath, accessor, database);

Liquibase executes the first 50 or 60 changesets normally and then suddenly stucks. It just stops and hangs endlessly. Increasing log level to FINEST gives no more output.
It took me some time of debugging to understand a little bit the Liquibase code and find the location where it gets stuck. The changesets are looped three times: The first time they are handled by a ValidatingVisitor, second loop by a ListVisitor. Both run without problems. The third loop is done by UpdateVisitor and there it stucks in method executeAcceptedChange when calling
Scope.getCurrentScope().getUI().sendMessage("Running Changeset: " + changeSet);

The sendMessage Method only prints the message to System.out.
It is quite unclear to me why printing a message to System.out should hang but when I comment the Scope.getCurrentScope… line Liquibase runs without any problem. For me it is not clear why Liquibase uses two mechanisms to log messages, one java logging and one printing to System.out. This is inconsistent and furthermore, the System.out logging cannot be controlled by the user.
I will now use a patched version where I replace the printing out System.out by java logging.