This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Flux<String> findAll(); | |
Mono<String> lookup(String s); | |
} | |
class Foo { | |
private final Service service; | |
Stream<String> problem() { | |
return service.findAll().toStream(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Flux<String> findAll(); | |
} | |
class Foo { | |
private final Service service; | |
Iterable<String> problem() { | |
return service.findAll().toIterable(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Flux<String> findAll(); | |
Mono<Void> operation(String s); | |
} | |
class Foo { | |
private final Service service; | |
Flux<Void> problem() { | |
return service.findAll() | |
.concatMap(service::operation); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Flux<String> findAll(); | |
Mono<Void> operation(String s); | |
} | |
class Foo { | |
private final Service service; | |
Flux<Void> problem() { | |
return service.findAll() | |
.flatMap(service::operation, 4); // parallelism=4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Flux<String> findAll(); | |
Mono<Void> operation(String s); | |
} | |
class Foo { | |
private final Service service; | |
Flux<Void> problem() { | |
return service.findAll() | |
.flatMap(service::operation); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class UploadService { | |
protected Mono<Void> doUpload(InputStream in); | |
Mono<Void> upload(InputStream in) { | |
doUpload(in).doFinally(x -> in.close()); | |
} | |
} | |
class Foo { | |
private final UploadService service; | |
Mono<Void> problem(byte[] data) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Flux<Integer> findAll(); | |
} | |
class Foo { | |
private final Service service; | |
Flux<Integer> problem() { | |
AtomicInteger count = new AtomicInteger(); | |
return service.findAll() | |
.doOnNext(count::addAndGet) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Mono<String> create(String s); | |
Mono<Void> update(String s); | |
} | |
class Foo { | |
private final Service service; | |
Mono<Integer> problem() { | |
return service.create("foo").flatMap(foo -> | |
service.update(foo).thenReturn(foo.length()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Mono<String> create(String s); | |
Mono<Void> update(String s); | |
} | |
class Foo { | |
private final Service service; | |
Mono<Integer> problem() { | |
return service.create("foo").map(foo -> { | |
service.update(foo).subscribe(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Service { | |
Mono<Void> update(String s); | |
} | |
class Foo { | |
private final Service service; | |
void problem() { | |
service.update("foo").onErrorResume(e -> { | |
e.printStackTrace(); | |
return Mono.empty(); |