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

Flyway auto-configuration does not work with Flyway 10 when using GraalVM #40821

Closed

Conversation

MazizEsa
Copy link

@MazizEsa MazizEsa commented May 19, 2024

In summary added compatibility with flyway 10 using reflection when initializing flyway scanner.
Add mechanism to check the dependency based on the mentioned flyway versions.
For #38923

2. Add test for flyway10 case
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 19, 2024
@MazizEsa MazizEsa changed the title Add compatibility for both flyway 10 for 38923 [DRAFT] Add compatibility for both flyway 10 for 38923 May 19, 2024
@MazizEsa MazizEsa marked this pull request as ready for review May 19, 2024 12:52
@MazizEsa MazizEsa changed the title [DRAFT] Add compatibility for both flyway 10 for 38923 Add compatibility for both flyway 10 for 38923 May 19, 2024
Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @MazizEsa.

In addition to my comment about avoiding reflection with Flyway 9. FlywayAutoConfiguration.FlywayAutoConfigurationRuntimeHints also needs to be updated to allow a Scanner instance to be created reflectively when using Flyway 10. This reflection hint should only be registered when a class that only exists in Flyway 10 is on the classpath.

Constructor<?> scannerConstructor;
Scanner scanner;
try {
scannerConstructor = ClassUtils.forName("org.flywaydb.core.internal.scanner.Scanner", null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to avoid reflection in the default case when using Flyway 9.

One way to do that would be to catch the NoSuchMethodError and then fall back to reflection. That fallback could even just assume that it's Flyway 10 and assume that Scanner will take 5 constructor arguments.

@wilkinsona wilkinsona changed the title Add compatibility for both flyway 10 for 38923 Flyway auto-configuration does not work with Flyway 10 when using GraalVM May 29, 2024
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 29, 2024
@wilkinsona wilkinsona added this to the 3.2.x milestone May 29, 2024
@wilkinsona wilkinsona self-assigned this May 29, 2024
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.7 May 29, 2024
wilkinsona pushed a commit that referenced this pull request May 29, 2024
wilkinsona added a commit that referenced this pull request May 29, 2024
wilkinsona added a commit that referenced this pull request May 29, 2024
wilkinsona added a commit that referenced this pull request May 29, 2024
* gh-40821:
  Polish "Fix Flyway 10 in a GraalVM native image"
  Fix Flyway 10 in a GraalVM native image

Closes gh-40821
@wilkinsona
Copy link
Member

Thank you, @MazizEsa, and congratulations on making your first contribution to Spring Boot.

@wilkinsona wilkinsona closed this May 29, 2024
@MazizEsa
Copy link
Author

MazizEsa commented Jun 1, 2024

Thanks @wilkinsona for polishing up. My apologies towards the end, I got busier with my work, hence slower in the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants