Suggestion: produce a meaningful error when the serializer can't be determined

I was running the generateChangeLog command and I ran into the following error:

INFO 6/14/11 10:15 AM:liquibase: c:\temp\test.diff exists, appending

Liquibase Update Failed: Unknown Reason

SEVERE 6/14/11 10:15 AM:liquibase: Unknown Reason


        at liquibase.diff.DiffResult.printChangeLog(

        at liquibase.diff.DiffResult.printChangeLog(

        at liquibase.diff.DiffResult.printChangeLog(

        at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(

        at liquibase.integration.commandline.Main.doMigration(

        at liquibase.integration.commandline.Main.main(

I checked out the code and ran it through the debugger.  I found that the serializer is determined from the file extension of the --changeLogFile parameter.  As I walked through the code in the debugger, there are two serializers set up: xml and txt.  If you provide a different extension for the output file (as I did), you’ll get a NPE as above because the code on line 405 in liquibase.diff.DiffResult will return null:

ChangeLogSerializer changeLogSerializer = serializerFactory.getSerializer(changeLogFile);

I would suggest doing the one of the following:

  1. at the very least, check after line 405 and make sure the serializer isn’t null – throw an exception with a meaningful message if it is – even better (because sooner), as part of the validation of the command-line arguments, make sure the given extension is valid; or

  2. perhaps change the SerializerFactory to default to either the xml or txt serializer if one can’t be found for the given extension

I’d be happy to submit a patch if it would help – let me know!

Thanks for the great tool!


A better error message would definitely be good.  If you wanted to submit a patch, that would be great


Thanks! I applied the change.


I attached a git diff to provide a better error message.  The change is in the ChangeLogSerializerFactory.  If serializers.get(fileNameOrExtension) returns null, the getSerializer method throws a RuntimeException with the message that there is no serializer for the filename or extension.