Return void from McpStatelessSyncServer#closeGracefully instead of Mono (#1019)
Co-authored-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com> Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
parent
275633775c
commit
c42d313975
3 changed files with 18 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ The changes fall into these areas:
|
||||||
- [JSON serialization behaviour](#json-serialization-behaviour) — wire-format changes.
|
- [JSON serialization behaviour](#json-serialization-behaviour) — wire-format changes.
|
||||||
- [Server-side validation](#server-side-validation) — runtime validation of tool arguments and embedded schemas.
|
- [Server-side validation](#server-side-validation) — runtime validation of tool arguments and embedded schemas.
|
||||||
- [Transport changes](#transport-changes) — removed methods and the SSE deprecation.
|
- [Transport changes](#transport-changes) — removed methods and the SSE deprecation.
|
||||||
|
- [Server API changes](#server-api-changes) — sync server method signature corrections.
|
||||||
- [New features](#new-features) — additive, backward-compatible capabilities.
|
- [New features](#new-features) — additive, backward-compatible capabilities.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -220,6 +221,18 @@ The HTTP+SSE client and server transports (and their supporting validator/except
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Server API changes
|
||||||
|
|
||||||
|
### `McpStatelessSyncServer#closeGracefully` returns `void`
|
||||||
|
|
||||||
|
In 1.x, `McpStatelessSyncServer.closeGracefully()` accidentally leaked the reactive signature from the underlying async server and returned `Mono<Void>`. The sync API is intentionally blocking, so returning a `Mono` was an oversight — callers had to call `.block()` themselves to get any actual shutdown behaviour.
|
||||||
|
|
||||||
|
In 2.0 the return type is corrected to `void`; the blocking call is performed internally.
|
||||||
|
|
||||||
|
**Action:** Remove any `.block()` (or `.subscribe()`) call you had appended to `closeGracefully()`. The method now blocks until the server has shut down and returns normally.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## New features
|
## New features
|
||||||
|
|
||||||
These are additive and backward-compatible.
|
These are additive and backward-compatible.
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ public class McpStatelessSyncServer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gracefully closes the server, allowing any in-progress operations to complete.
|
* Gracefully closes the server, allowing any in-progress operations to complete.
|
||||||
* @return A Mono that completes when the server has been closed
|
*
|
||||||
*/
|
*/
|
||||||
public Mono<Void> closeGracefully() {
|
public void closeGracefully() {
|
||||||
return this.asyncServer.closeGracefully();
|
this.asyncServer.closeGracefully().block();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
package io.modelcontextprotocol;
|
package io.modelcontextprotocol;
|
||||||
|
|
||||||
import static io.modelcontextprotocol.util.ToolsUtils.EMPTY_JSON_SCHEMA;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
|
|
@ -31,9 +29,9 @@ import io.modelcontextprotocol.spec.McpSchema.Tool;
|
||||||
import net.javacrumbs.jsonunit.core.Option;
|
import net.javacrumbs.jsonunit.core.Option;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import static io.modelcontextprotocol.util.ToolsUtils.EMPTY_JSON_SCHEMA;
|
||||||
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
|
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
|
||||||
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.json;
|
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.json;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
@ -128,7 +126,7 @@ public abstract class AbstractStatelessIntegrationTests {
|
||||||
assertThat(response).isNotNull().isEqualTo(callResponse);
|
assertThat(response).isNotNull().isEqualTo(callResponse);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
mcpServer.closeGracefully().block();
|
mcpServer.closeGracefully();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue