snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Flyway 8.1.0 with SQL Server fails in native with `NullPointerException` #456

Closed snowdrop-bot closed 2 years ago

snowdrop-bot commented 2 years ago

Describe the bug

Flyway 8.1.0 together with SQL Server fails on native application startup, throwing a NPE due to a missing resource:

org/flywaydb/database/version.txt

POM dependencies sample:

    ...
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-flyway</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-sqlserver</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-mssql</artifactId>
    </dependency>
    ...

Workaround: explicitly include the missing resource in application.properties:

quarkus.native.resources.includes=org/flywaydb/database/version.txt

Expected behavior

No NullPointerException on startup.

Actual behavior

2021-12-01 07:54:02,142 INFO  [org.fly.cor.int.lic.VersionPrinter] (main) Flyway Community Edition 8.1.0 by Redgate
2021-12-01 07:54:02,144 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.NullPointerException
    at org.flywaydb.core.internal.util.FileCopyUtils.copy(FileCopyUtils.java:121)
    at org.flywaydb.core.internal.util.FileCopyUtils.copyToString(FileCopyUtils.java:81)
    at org.flywaydb.database.SQLServerDatabaseExtension.readVersion(SQLServerDatabaseExtension.java:32)
    at org.flywaydb.database.SQLServerDatabaseExtension.getDescription(SQLServerDatabaseExtension.java:27)
    at org.flywaydb.core.internal.license.VersionPrinter.printExtensionVersions(VersionPrinter.java:61)
    at org.flywaydb.core.internal.license.VersionPrinter.printVersionOnly(VersionPrinter.java:56)
    at org.flywaydb.core.internal.license.VersionPrinter.printVersion(VersionPrinter.java:51)
    at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:170)
    at org.flywaydb.core.Flyway.migrate(Flyway.java:124)
    at io.quarkus.flyway.runtime.FlywayRecorder.doStartActions(FlywayRecorder.java:76)
    at io.quarkus.deployment.steps.FlywayProcessor$createBeansAndStartActions2063183959.deploy_0(Unknown Source)
    at io.quarkus.deployment.steps.FlywayProcessor$createBeansAndStartActions2063183959.deploy(Unknown Source)
    at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
    at io.quarkus.runtime.Application.start(Application.java:101)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:104)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
    at io.quarkus.runner.GeneratedMain.main(Unknown Source)

How to Reproduce?

flyway-sqlserver-reproducer.zip

Use the attached reproducer.

unzip flyway-sqlserver-reproducer.zip
cd flyway-sqlserver-reproducer

Build Quarkus main (2.6 - main) or configure Maven to use a repository with daily snapshot. Then run:

./mvnw clean verify -Pnative

Output of uname -a or ver

No response

Output of java -version

openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

GraalVM version (if different from Java)

GraalVM 21.2.0 Java 16 CE (Java Version 16.0.2+7-jvmci-21.2-b08)

Quarkus version or git rev

999-SNAPSHOT (2.6 - main)

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.3

Additional information

No response


https://github.com/quarkusio/quarkus/issues/21835


$upstream:21835$