Skip to content

Commit 370d804

Browse files
committed
Add Flow to Publisher fallback converter
1 parent 71310c8 commit 370d804

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

runtime/src/main/java/io/micronaut/reactive/flow/converters/FlowConverterRegistrar.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
import io.reactivex.Flowable;
2222
import kotlinx.coroutines.flow.Flow;
2323
import kotlinx.coroutines.reactive.ReactiveFlowKt;
24+
import org.reactivestreams.Publisher;
2425

2526
import javax.inject.Singleton;
27+
import java.util.function.Function;
2628

2729
/**
28-
* Converts between a {@link Flow} and a {@link Flowable}.
30+
* Converts between a {@link Flow} and a {@link Publisher}.
2931
*
3032
* @author Konrad Kamiński
3133
* @since 1.3
@@ -36,8 +38,10 @@ public class FlowConverterRegistrar implements TypeConverterRegistrar {
3638
@Override
3739
public void register(ConversionService<?> conversionService) {
3840
// Flow
39-
conversionService.addConverter(Flow.class, Flowable.class,
40-
flow -> Flowable.fromPublisher(ReactiveFlowKt.asPublisher(flow)));
41-
conversionService.addConverter(Flowable.class, Flow.class, ReactiveFlowKt::asFlow);
41+
conversionService.addConverter(Flow.class, Flowable.class, (Function<Flow, Flowable>) flow ->
42+
Flowable.fromPublisher(ReactiveFlowKt.asPublisher(flow))
43+
);
44+
conversionService.addConverter(Flow.class, Publisher.class, ReactiveFlowKt::asPublisher);
45+
conversionService.addConverter(Publisher.class, Flow.class, ReactiveFlowKt::asFlow);
4246
}
4347
}

src/main/docs/guide/introduction/whatsNew.adoc

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Micronaut {version} includes the following changes:
44

55
Micronaut now supports creating native-images using GraalVM 19.3.0 for both JDK 8 and JDK 11.
66

7+
=== Startup and Memory Usage Optimizations
8+
9+
Startup performance and memory usage (20%) have been improved.
10+
711
=== Micronaut Data Integration
812

913
Micronaut Data has been added to the `micronaut-bom` and you can now use the CLI to create Micronaut Data projects:
@@ -22,6 +26,12 @@ $ mn create-app myapp --features data-hibernate-jpa
2226
$ mn create-app myapp --features data-jdbc
2327
----
2428

29+
=== Initial Support for Kotlin Coroutines and Flow
30+
31+
Initial support for Kotlin Coroutines and the `Flow` type has been added when used as the return type of controller methods.
32+
33+
Thanks to https://github.com/konrad-kaminski[Konrad Kamiński] for this contribution.
34+
2535
=== Immutable `@ConfigurationProperties` and `@EachProperty`
2636

2737
Support for immutable ann:context.annotation.ConfigurationProperties[] has been added by annotating the constructor of any configuration class with ann:context.annotation.ConfigurationInject[]. See the docummentation on <<immutableConfig, Immutable Configuration>> for more information.
@@ -32,6 +42,12 @@ snippet::io.micronaut.docs.config.itfce.EngineConfig[tags="imports,class",indent
3242

3343
https://micronaut-projects.github.io/micronaut-cache/1.0.x/guide/#introduction[Micronaut Cache] has been updated to support https://micronaut-projects.github.io/micronaut-cache/1.0.x/guide/#hazelcast[Hazelcast] and https://micronaut-projects.github.io/micronaut-cache/1.0.x/guide/#ehcache[Ehcache] as additional Cache providers.
3444

45+
=== New Micronaut Jackson XML Module
46+
47+
Support for parsing and serializing to XML has been added with a new https://github.com/micronaut-projects/micronaut-jackson-xml[Jackson XML module].
48+
49+
Thanks to https://github.com/svishnyakoff[Sergey] for this contribution.
50+
3551
=== Micronaut OpenAPI (Swagger) 1.3 Update
3652

3753
Micronaut OpenAPI has been updated with loads of improvements including the ability to https://micronaut-projects.github.io/micronaut-openapi/1.3.x/guide/index.html#openApiViews[automatically generate UIs for Swagger output] as part of your application. Thanks to https://github.com/croudet[croudet] for this contribution awesome contribution.

0 commit comments

Comments
 (0)