Skip to content

Conversation

He-Pin
Copy link
Contributor

@He-Pin He-Pin commented May 12, 2025

It should be Mono#then as it's a Mono<Void>

Motivation and Context

Avoid some warning.

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@He-Pin He-Pin marked this pull request as ready for review May 12, 2025 06:43
@@ -314,7 +314,7 @@ private Mono<ServerResponse> handleMessage(ServerRequest request) {
return request.bodyToMono(String.class).flatMap(body -> {
try {
McpSchema.JSONRPCMessage message = McpSchema.deserializeJsonRpcMessage(objectMapper, body);
return session.handle(message).flatMap(response -> ServerResponse.ok().build()).onErrorResume(error -> {
return session.handle(message).then(Mono.defer(() -> ServerResponse.ok().build())).onErrorResume(error -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to call the Mono.defer()?
Since the ServerResponse.ok().build() returns a Mono and the execution is lazy.

Mono.defer() creates a runtime wrapper as unnecessary overhead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, yes, the defer is nuneeded

@He-Pin He-Pin closed this May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants