Skip to content

Commit 2d16692

Browse files
mp911dechristophstrobl
authored andcommitted
Use constant fields for Reactive Wrapper Converters guards.
Enables reachability analysis. Previously, the presence checks were using method invocations and the AOT processing isn't following the methods. Original Pull Request: #2624
1 parent e71f7c2 commit 2d16692

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/main/java/org/springframework/data/repository/util/ReactiveWrapperConverters.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,34 @@ public abstract class ReactiveWrapperConverters {
6464
private static final List<ReactiveTypeWrapper<?>> REACTIVE_WRAPPERS = new ArrayList<>();
6565
private static final GenericConversionService GENERIC_CONVERSION_SERVICE = new GenericConversionService();
6666

67+
private static final boolean RXJAVA3_PRESENT = ReactiveWrappers.isAvailable(ReactiveLibrary.RXJAVA3);
68+
private static final boolean REACTOR_PRESENT = ReactiveWrappers.isAvailable(ReactiveLibrary.PROJECT_REACTOR);
69+
private static final boolean KOTLIN_COROUTNES_PRESENT = ReactiveWrappers
70+
.isAvailable(ReactiveLibrary.KOTLIN_COROUTINES);
71+
private static final boolean MUTINY_PRESENT = ReactiveWrappers.isAvailable(ReactiveLibrary.MUTINY);
72+
6773
static {
6874

69-
if (ReactiveWrappers.isAvailable(ReactiveLibrary.RXJAVA3)) {
75+
if (RXJAVA3_PRESENT) {
7076

7177
REACTIVE_WRAPPERS.add(RxJava3SingleWrapper.INSTANCE);
7278
REACTIVE_WRAPPERS.add(RxJava3MaybeWrapper.INSTANCE);
7379
REACTIVE_WRAPPERS.add(RxJava3ObservableWrapper.INSTANCE);
7480
REACTIVE_WRAPPERS.add(RxJava3FlowableWrapper.INSTANCE);
7581
}
7682

77-
if (ReactiveWrappers.isAvailable(ReactiveLibrary.PROJECT_REACTOR)) {
83+
if (REACTOR_PRESENT) {
7884

7985
REACTIVE_WRAPPERS.add(FluxWrapper.INSTANCE);
8086
REACTIVE_WRAPPERS.add(MonoWrapper.INSTANCE);
8187
REACTIVE_WRAPPERS.add(PublisherWrapper.INSTANCE);
8288
}
8389

84-
if (ReactiveWrappers.isAvailable(ReactiveLibrary.KOTLIN_COROUTINES)) {
90+
if (KOTLIN_COROUTNES_PRESENT) {
8591
REACTIVE_WRAPPERS.add(FlowWrapper.INSTANCE);
8692
}
8793

88-
if (ReactiveWrappers.isAvailable(ReactiveLibrary.MUTINY)) {
94+
if (MUTINY_PRESENT) {
8995
REACTIVE_WRAPPERS.add(UniWrapper.INSTANCE);
9096
REACTIVE_WRAPPERS.add(MultiWrapper.INSTANCE);
9197
}
@@ -104,12 +110,12 @@ private static ConversionService registerConvertersIn(ConfigurableConversionServ
104110

105111
Assert.notNull(conversionService, "ConversionService must not be null");
106112

107-
if (ReactiveWrappers.isAvailable(ReactiveLibrary.PROJECT_REACTOR)) {
113+
if (REACTOR_PRESENT) {
108114

109115
conversionService.addConverter(PublisherToMonoConverter.INSTANCE);
110116
conversionService.addConverter(PublisherToFluxConverter.INSTANCE);
111117

112-
if (ReactiveWrappers.isAvailable(ReactiveLibrary.KOTLIN_COROUTINES)) {
118+
if (KOTLIN_COROUTNES_PRESENT) {
113119
conversionService.addConverter(PublisherToFlowConverter.INSTANCE);
114120
}
115121

@@ -439,7 +445,6 @@ public io.smallrye.mutiny.Multi<?> map(Object wrapper, Function<Object, Object>
439445
}
440446
}
441447

442-
443448
// -------------------------------------------------------------------------
444449
// ReactiveStreams converters
445450
// -------------------------------------------------------------------------

0 commit comments

Comments
 (0)