Skip to content

Commit 5470a6b

Browse files
committed
Call FlywayConfigurationCustomizers after applying all other config
Closes gh-32070
1 parent d546ea5 commit 5470a6b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ public Flyway flyway(FlywayProperties properties, ResourceLoader resourceLoader,
119119
configureProperties(configuration, properties);
120120
List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList());
121121
configureCallbacks(configuration, orderedCallbacks);
122-
fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration));
123-
configureFlywayCallbacks(configuration, orderedCallbacks);
124122
List<JavaMigration> migrations = javaMigrations.stream().collect(Collectors.toList());
125123
configureJavaMigrations(configuration, migrations);
124+
fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration));
126125
return configuration.load();
127126
}
128127

@@ -245,12 +244,6 @@ private void configureCallbacks(FluentConfiguration configuration, List<Callback
245244
}
246245
}
247246

248-
private void configureFlywayCallbacks(FluentConfiguration flyway, List<Callback> callbacks) {
249-
if (!callbacks.isEmpty()) {
250-
flyway.callbacks(callbacks.toArray(new Callback[0]));
251-
}
252-
}
253-
254247
private void configureJavaMigrations(FluentConfiguration flyway, List<JavaMigration> migrations) {
255248
if (!migrations.isEmpty()) {
256249
flyway.javaMigrations(migrations.toArray(new JavaMigration[0]));

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,17 @@ void configurationCustomizersAreConfiguredAndOrdered() {
467467
});
468468
}
469469

470+
@Test
471+
void callbackAndMigrationBeansAreAppliedToConfigurationBeforeCustomizersAreCalled() {
472+
this.contextRunner
473+
.withUserConfiguration(EmbeddedDataSourceConfiguration.class, FlywayJavaMigrationsConfiguration.class,
474+
CallbackConfiguration.class)
475+
.withBean(FlywayConfigurationCustomizer.class, () -> (configuration) -> {
476+
assertThat(configuration.getCallbacks()).isNotEmpty();
477+
assertThat(configuration.getJavaMigrations()).isNotEmpty();
478+
}).run((context) -> assertThat(context).hasNotFailed());
479+
}
480+
470481
@Test
471482
void batchIsCorrectlyMapped() {
472483
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)

0 commit comments

Comments
 (0)