@@ -289,9 +289,9 @@ private Mono<Void> handleSingleJson(final HttpResponse<InputStream> response,
289
289
final Function <Mono <McpSchema .JSONRPCMessage >, Mono <McpSchema .JSONRPCMessage >> handler ) {
290
290
return Mono .fromCallable (() -> {
291
291
try {
292
- final McpSchema .JSONRPCMessage msg = McpSchema .deserializeJsonRpcMessage (objectMapper ,
293
- new String (response .body ().readAllBytes (), StandardCharsets .UTF_8 ));
294
- return handler .apply (Mono .just (msg ));
292
+ final McpSchema .JSONRPCMessage msg = McpSchema .deserializeJsonRpcMessage (objectMapper ,
293
+ new String (response .body ().readAllBytes (), StandardCharsets .UTF_8 ));
294
+ return handler .apply (Mono .just (msg ));
295
295
}
296
296
catch (IOException e ) {
297
297
LOGGER .error ("Error processing JSON response" , e );
@@ -349,26 +349,30 @@ else if (line.startsWith("id: "))
349
349
for (JsonNode item : node ) {
350
350
messages .add (McpSchema .deserializeJsonRpcMessage (objectMapper , item .toString ()));
351
351
}
352
- } else if (node .isObject ()) {
352
+ }
353
+ else if (node .isObject ()) {
353
354
messages .add (McpSchema .deserializeJsonRpcMessage (objectMapper , node .toString ()));
354
- } else {
355
+ }
356
+ else {
355
357
String warning = "Unexpected JSON in SSE data: " + rawData ;
356
358
LOGGER .warn ("Unexpected JSON in SSE data: {}" , rawData );
357
359
return Mono .error (new IllegalArgumentException (warning ));
358
360
}
359
361
360
362
return Flux .fromIterable (messages )
361
- .concatMap (msg -> handler .apply (Mono .just (msg )))
362
- .then (Mono .fromRunnable (() -> {
363
- if (!sseEvent .id ().isEmpty ()) {
364
- lastEventId .set (sseEvent .id ());
365
- }
366
- }));
367
- } catch (IOException e ) {
363
+ .concatMap (msg -> handler .apply (Mono .just (msg )))
364
+ .then (Mono .fromRunnable (() -> {
365
+ if (!sseEvent .id ().isEmpty ()) {
366
+ lastEventId .set (sseEvent .id ());
367
+ }
368
+ }));
369
+ }
370
+ catch (IOException e ) {
368
371
LOGGER .error ("Error parsing SSE JSON: {}" , rawData , e );
369
372
return Mono .error (e );
370
373
}
371
- }).then ();
374
+ })
375
+ .then ();
372
376
}
373
377
374
378
@ Override
0 commit comments