@@ -280,22 +280,25 @@ void registerAdapters(ReactiveAdapterRegistry registry) {
280
280
private static class ReactorJdkFlowAdapterRegistrar {
281
281
282
282
void registerAdapter (ReactiveAdapterRegistry registry ) throws Exception {
283
+
283
284
// TODO: remove reflection when build requires JDK 9+
284
- Class <?> type = ClassUtils .forName ("java.util.concurrent.Flow.Publisher" , getClass ().getClassLoader ());
285
- Method toFluxMethod = getMethod ("flowPublisherToFlux" , type );
286
- Method toFlowMethod = getMethod ("publisherToFlowPublisher" , Publisher .class );
285
+
286
+ String publisherName = "java.util.concurrent.Flow.Publisher" ;
287
+ Class <?> publisherClass = ClassUtils .forName (publisherName , getClass ().getClassLoader ());
288
+
289
+ String adapterName = "reactor.adapter.JdkFlowAdapter" ;
290
+ Class <?> flowAdapterClass = ClassUtils .forName (adapterName , getClass ().getClassLoader ());
291
+
292
+ Method toFluxMethod = flowAdapterClass .getMethod ("flowPublisherToFlux" , publisherClass );
293
+ Method toFlowMethod = flowAdapterClass .getMethod ("publisherToFlowPublisher" , Publisher .class );
287
294
Object emptyFlow = ReflectionUtils .invokeMethod (toFlowMethod , null , Flux .empty ());
288
295
289
296
registry .registerReactiveType (
290
- ReactiveTypeDescriptor .multiValue (type , () -> emptyFlow ),
297
+ ReactiveTypeDescriptor .multiValue (publisherClass , () -> emptyFlow ),
291
298
source -> (Publisher <?>) ReflectionUtils .invokeMethod (toFluxMethod , null , source ),
292
299
publisher -> ReflectionUtils .invokeMethod (toFlowMethod , null , publisher )
293
300
);
294
301
}
295
-
296
- private static Method getMethod (String name , Class <?> argumentType ) throws NoSuchMethodException {
297
- return reactor .adapter .JdkFlowAdapter .class .getMethod (name , argumentType );
298
- }
299
302
}
300
303
301
304
0 commit comments