From eadbe80f039442daba9c1015766b61b3612d8285 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 22 Sep 2020 16:07:52 +0200 Subject: [PATCH] =?UTF-8?q?DATACMNS-1802=20-=20Extract=20Flux.from(?= =?UTF-8?q?=E2=80=A6)=20into=20own=20method.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../repository/core/support/RepositoryMethodInvoker.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/data/repository/core/support/RepositoryMethodInvoker.java b/src/main/java/org/springframework/data/repository/core/support/RepositoryMethodInvoker.java index d458a4a83..724696227 100644 --- a/src/main/java/org/springframework/data/repository/core/support/RepositoryMethodInvoker.java +++ b/src/main/java/org/springframework/data/repository/core/support/RepositoryMethodInvoker.java @@ -179,7 +179,7 @@ abstract class RepositoryMethodInvoker { } if (Collection.class.isAssignableFrom(returnedType)) { - result = Flux.from(result).collectList(); + result = (Publisher) collectToList(result); } return AwaitKt.awaitFirstOrNull(result, continuation); @@ -189,6 +189,11 @@ abstract class RepositoryMethodInvoker { } } + // to avoid NoClassDefFoundError: org/reactivestreams/Publisher when loading this class ¯\_(ツ)_/¯ + private static Object collectToList(Object result) { + return Flux.from((Publisher) result).collectList(); + } + private RepositoryMethodInvocation computeInvocationResult(RepositoryMethodInvocationCaptor captured) { return new RepositoryMethodInvocation(captured.getRepositoryInterface(), method, captured.getCapturedResult(), captured.getDuration());