Skip to content

Commit 812c965

Browse files
committed
#276 add Ordered interface to internal bean post processors to ensure correct processing order
1 parent 49e474f commit 812c965

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

embedded-database-spring-test/src/main/java/io/zonky/test/db/flyway/FlywayDatabaseExtension.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.springframework.aop.framework.ProxyFactory;
4141
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;
4242
import org.springframework.beans.factory.config.BeanPostProcessor;
43+
import org.springframework.core.Ordered;
4344

4445
import java.util.Arrays;
4546
import java.util.Collection;
@@ -59,7 +60,7 @@
5960

6061
import static com.google.common.base.Preconditions.checkState;
6162

62-
public class FlywayDatabaseExtension implements BeanPostProcessor {
63+
public class FlywayDatabaseExtension implements BeanPostProcessor, Ordered {
6364

6465
private static final FlywayVersion flywayVersion = FlywayClassUtils.getFlywayVersion();
6566

@@ -68,6 +69,11 @@ public class FlywayDatabaseExtension implements BeanPostProcessor {
6869
protected final Multimap<DatabaseContext, Flyway> flywayBeans = HashMultimap.create();
6970
protected final BlockingQueue<FlywayOperation> pendingOperations = new LinkedBlockingQueue<>();
7071

72+
@Override
73+
public int getOrder() {
74+
return Ordered.HIGHEST_PRECEDENCE + 1;
75+
}
76+
7177
@Override
7278
public Object postProcessBeforeInitialization(Object bean, String beanName) {
7379
if (bean instanceof AopInfrastructureBean) {

embedded-database-spring-test/src/main/java/io/zonky/test/db/flyway/FlywayPropertiesPostProcessor.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
import org.springframework.beans.BeansException;
44
import org.springframework.beans.factory.config.BeanPostProcessor;
55
import org.springframework.boot.autoconfigure.flyway.FlywayProperties;
6+
import org.springframework.core.Ordered;
67

7-
public class FlywayPropertiesPostProcessor implements BeanPostProcessor {
8+
public class FlywayPropertiesPostProcessor implements BeanPostProcessor, Ordered {
9+
10+
@Override
11+
public int getOrder() {
12+
return Ordered.LOWEST_PRECEDENCE - 1;
13+
}
814

915
@Override
1016
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

embedded-database-spring-test/src/main/java/io/zonky/test/db/liquibase/LiquibaseDatabaseExtension.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
import org.springframework.aop.framework.ProxyFactory;
2929
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;
3030
import org.springframework.beans.factory.config.BeanPostProcessor;
31+
import org.springframework.core.Ordered;
3132

3233
import static com.google.common.base.Preconditions.checkState;
3334

34-
public class LiquibaseDatabaseExtension implements BeanPostProcessor {
35+
public class LiquibaseDatabaseExtension implements BeanPostProcessor, Ordered {
36+
37+
@Override
38+
public int getOrder() {
39+
return Ordered.HIGHEST_PRECEDENCE + 1;
40+
}
3541

3642
@Override
3743
public Object postProcessBeforeInitialization(Object bean, String beanName) {

embedded-database-spring-test/src/main/java/io/zonky/test/db/liquibase/LiquibasePropertiesPostProcessor.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@
1919
import org.springframework.beans.BeansException;
2020
import org.springframework.beans.factory.config.BeanPostProcessor;
2121
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
22+
import org.springframework.core.Ordered;
2223

23-
public class LiquibasePropertiesPostProcessor implements BeanPostProcessor {
24+
public class LiquibasePropertiesPostProcessor implements BeanPostProcessor, Ordered {
25+
26+
@Override
27+
public int getOrder() {
28+
return Ordered.LOWEST_PRECEDENCE - 1;
29+
}
2430

2531
@Override
2632
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

0 commit comments

Comments
 (0)