From 29100c3d4745b2891151b0f03819b47fbc8a174a Mon Sep 17 00:00:00 2001 From: Roman Mitasov Date: Wed, 21 Jun 2023 13:56:32 +0600 Subject: [PATCH] Fix NPE in JsonReaderHttpServerRequestMapper#apply Resolves #168 --- .../http/server/JsonReaderHttpServerRequestMapper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/json/json-module/src/main/java/ru/tinkoff/kora/json/module/http/server/JsonReaderHttpServerRequestMapper.java b/json/json-module/src/main/java/ru/tinkoff/kora/json/module/http/server/JsonReaderHttpServerRequestMapper.java index c514416c5..279e3d6bd 100644 --- a/json/json-module/src/main/java/ru/tinkoff/kora/json/module/http/server/JsonReaderHttpServerRequestMapper.java +++ b/json/json-module/src/main/java/ru/tinkoff/kora/json/module/http/server/JsonReaderHttpServerRequestMapper.java @@ -19,7 +19,12 @@ public Mono apply(HttpServerRequest request) { return ReactorUtils.toByteArrayMono(request.body()) .handle((bytes, sink) -> { try { - sink.next(this.reader.read(bytes)); + var body = this.reader.read(bytes) + if (body != null) { + sink.next(); + } else { + sink.complete(); + } } catch (Exception e) { var httpException = HttpServerResponseException.of(e, 400, e.getMessage()); sink.error(httpException);