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

Closed
gregorko opened this issue Sep 5, 2019 · 1 comment

Comments

@gregorko
Copy link

commented Sep 5, 2019

Which version and edition of Flyway are you using?

6.0.1

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

Gradle

Which database are you using (type & version)?

MySQL 5.7

Which operating system are you using?

Windows

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;
EXECUTE stmt;
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(AsciiTable.java:54)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.outputQueryResult(DefaultSqlScriptExecutor.java:260)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.handleResults(DefaultSqlScriptExecutor.java:253)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:230)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.execute(DefaultSqlScriptExecutor.java:127)
        at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:70)
        at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:366)
        at org.flywaydb.core.internal.command.DbMigrate.access$200(DbMigrate.java:54)
        at org.flywaydb.core.internal.command.DbMigrate$3.call(DbMigrate.java:282)
        at org.flywaydb.core.internal.jdbc.TransactionTemplate.execute(TransactionTemplate.java:74)
        at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:279)
        at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:244)
        at org.flywaydb.core.internal.command.DbMigrate.access$100(DbMigrate.java:54)
        at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:162)
        at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:159)
        at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.execute(MySQLNamedLockTemplate.java:60)
        at org.flywaydb.core.internal.database.mysql.MySQLConnection.lock(MySQLConnection.java:161)
        at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:139)
        at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:159)
        at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:137)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:182)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:142)
        at org.flywaydb.core.Flyway.execute(Flyway.java:504)
        at org.flywaydb.core.Flyway.migrate(Flyway.java:142)
        at org.flywaydb.gradle.task.FlywayMigrateTask.run(FlywayMigrateTask.java:28)
        at org.flywaydb.gradle.task.AbstractFlywayTask.runTask(AbstractFlywayTask.java:517)
        ... 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

@alextercete

This comment has been minimized.

Copy link
Member

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
Projects
None yet
2 participants
You can’t perform that action at this time.