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

Nullpointer on java-based migration #3092

Labels
Milestone

Comments

@eikek
Copy link

eikek commented Feb 24, 2021

Which version and edition of Flyway are you using?

7.5.4

If this is not the latest version, can you reproduce the issue with the latest one as well? (Many bugs are fixed in newer releases and upgrading will often resolve the issue)

I'm using the newest version.

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

Java-API.

Which database are you using? (Type & version)

H2 1.4.200, MS-SQL

Which operating system are you using?

GNU/Linux

What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)

I created a java-based Migration as described here. The migration creates a simple table. The migration is picked up by Flyway and tried to execute.

However, it fails to create a ResolvedMigration, because of a NPE inside ClassUtils, line 196:

ProtectionDomain protectionDomain = aClass.getProtectionDomain();
if (protectionDomain == null) {
    //Android
    return null;
}
CodeSource codeSource = protectionDomain.getCodeSource();
if (codeSource == null) {
    //Custom classloader with for example classes defined using URLClassLoader#defineClass(String name, byte[] b, int off, int len)
    return null;
}
return UrlUtils.decodeURL(codeSource.getLocation().getPath()); //196

In our case (we are using Guice), the CodeSource is non-null, but all fields in there are null, i.e. getLocation() returns null, which results in the NPE when accessing getPath.

What did you expect to see?

I expect Flyway to check for null for all properties in CodeSource. It doesn't state in it's api docs that it's always non-null.

What did you see instead?

A NPE is thrown.

Thank you!

@eikek eikek changed the title Nullpointer on javabased migration Nullpointer on java-based migration Feb 24, 2021
@DoodleBobBuffPants DoodleBobBuffPants added this to the Flyway 7.x milestone Feb 24, 2021
This was referenced Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment