Skip to content

Commit

Permalink
Close input stream on CloudEventHttpMessageReader (#421)
Browse files Browse the repository at this point in the history
Signed-off-by: Joke de Buhr <joke.debuhr@eventim.de>
  • Loading branch information
joke committed Nov 3, 2021
1 parent 32adfe9 commit a94bc5c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -62,8 +63,8 @@ public Mono<CloudEvent> readMono(ResolvableType elementType, ReactiveHttpInputMe
Map<String, Object> hints) {
HttpHeaders headers = message.getHeaders();
Mono<byte[]> body = DataBufferUtils.join(message.getBody()).map(buffer -> {
try {
return StreamUtils.copyToByteArray(buffer.asInputStream(true));
try (InputStream inputStream = buffer.asInputStream(true)) {
return StreamUtils.copyToByteArray(inputStream);
}
catch (Exception e) {
throw new IllegalArgumentException(e);
Expand Down

0 comments on commit a94bc5c

Please sign in to comment.