Skip to content

Commit eadbe80

Browse files
committed
DATACMNS-1802 - Extract Flux.from(…) into own method.
For some reason, calling Flux.from(…) in its own, static method, heals NoClassDefFoundError even though the method is not used during runtime nor Publisher is defined in a method signature.
1 parent b3d0fea commit eadbe80

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/org/springframework/data/repository/core/support/RepositoryMethodInvoker.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private Object doInvokeReactiveToSuspended(Class<?> repositoryInterface, Reposit
179179
}
180180

181181
if (Collection.class.isAssignableFrom(returnedType)) {
182-
result = Flux.from(result).collectList();
182+
result = (Publisher<?>) collectToList(result);
183183
}
184184

185185
return AwaitKt.awaitFirstOrNull(result, continuation);
@@ -189,6 +189,11 @@ private Object doInvokeReactiveToSuspended(Class<?> repositoryInterface, Reposit
189189
}
190190
}
191191

192+
// to avoid NoClassDefFoundError: org/reactivestreams/Publisher when loading this class ¯\_(ツ)_/¯
193+
private static Object collectToList(Object result) {
194+
return Flux.from((Publisher<?>) result).collectList();
195+
}
196+
192197
private RepositoryMethodInvocation computeInvocationResult(RepositoryMethodInvocationCaptor captured) {
193198
return new RepositoryMethodInvocation(captured.getRepositoryInterface(), method, captured.getCapturedResult(),
194199
captured.getDuration());

0 commit comments

Comments
 (0)