Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in AsciiTable.render #2496

gregorko opened this issue Sep 5, 2019 · 1 comment


Copy link

commented Sep 5, 2019

Which version and edition of Flyway are you using?


Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)


Which database are you using (type & version)?

MySQL 5.7

Which operating system are you using?


What did you do?

The following migration script caused the issue:

set @idxTable := 'myTable';
set @idxName := 'myIndex';
set @exist := (select count(*) from information_schema.statistics where table_name = @idxTable and index_name = @idxName and table_schema = database());
set @sqlstmt := if( @exist > 0, concat('drop index ', @idxName, ' on ', @idxTable), 'select ''''');
PREPARE stmt FROM @sqlstmt;
What did you expect to see?

No exception

What did you see instead?
Caused by: java.lang.NullPointerException
        at org.flywaydb.core.internal.util.AsciiTable.render(
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.outputQueryResult(
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.handleResults(
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.execute(
        at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(
        at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(
        at org.flywaydb.core.internal.command.DbMigrate.access$200(
        at org.flywaydb.core.internal.command.DbMigrate$
        at org.flywaydb.core.internal.jdbc.TransactionTemplate.execute(
        at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(
        at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(
        at org.flywaydb.core.internal.command.DbMigrate.access$100(
        at org.flywaydb.core.internal.command.DbMigrate$
        at org.flywaydb.core.internal.command.DbMigrate$
        at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.execute(
        at org.flywaydb.core.internal.database.mysql.MySQLConnection.lock(
        at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(
        at org.flywaydb.core.internal.command.DbMigrate.migrateAll(
        at org.flywaydb.core.internal.command.DbMigrate.migrate(
        at org.flywaydb.core.Flyway$1.execute(
        at org.flywaydb.core.Flyway$1.execute(
        at org.flywaydb.core.Flyway.execute(
        at org.flywaydb.core.Flyway.migrate(
        at org.flywaydb.gradle.task.AbstractFlywayTask.runTask(
        ... 87 more

I was able to debug this down to the following:
JdbcTemplate.extractResults() tries to read metadata.getColumnName. But the column name returned is null. This adds a single column with null to the columns array and causes AsciiTable to throw a NPE. Maybe in case the column name is null you could use the column type. Which would be VARCHAR in my case.

The problem doesn't appear with 5.2.4

@alextercete alextercete added the t: bug label Sep 5, 2019

@alextercete alextercete added this to the Flyway 6.0.2 milestone Sep 5, 2019


This comment has been minimized.

Copy link

commented Sep 5, 2019

@gregorko Thanks for the report!

We've managed to reproduce the issue and we'll release a fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.