@@ -37,9 +37,6 @@ private InitializeResult initialization(McpAsyncClient asyncMcpClient, MockMcpTr
3737 .build (),
3838 new McpSchema .Implementation ("test-server" , "1.0.0" ), "Test instructions" );
3939
40- // Use CountDownLatch to coordinate between threads
41- java .util .concurrent .CountDownLatch latch = new java .util .concurrent .CountDownLatch (1 );
42-
4340 // Create a Mono that will handle the initialization and response simulation
4441 return asyncMcpClient .initialize ().doOnSubscribe (subscription -> {
4542 // Run in a separate reactive context to avoid blocking the main subscription
@@ -51,17 +48,7 @@ private InitializeResult initialization(McpAsyncClient asyncMcpClient, MockMcpTr
5148 McpSchema .JSONRPCResponse initResponse = new McpSchema .JSONRPCResponse (McpSchema .JSONRPC_VERSION ,
5249 initRequest .id (), mockInitResult , null );
5350 transport .simulateIncomingMessage (initResponse );
54- latch .countDown ();
5551 }).subscribeOn (reactor .core .scheduler .Schedulers .boundedElastic ()).subscribe ();
56- }).doOnTerminate (() -> {
57- try {
58- // Wait for the response simulation to complete
59- latch .await (5 , java .util .concurrent .TimeUnit .SECONDS );
60- }
61- catch (InterruptedException e ) {
62- Thread .currentThread ().interrupt ();
63- throw new RuntimeException ("Interrupted while waiting for initialization" , e );
64- }
6552 }).block ();
6653 }
6754
@@ -82,9 +69,6 @@ void testSuccessfulInitialization() {
8269 McpSchema .InitializeResult mockInitResult = new McpSchema .InitializeResult (McpSchema .LATEST_PROTOCOL_VERSION ,
8370 mockServerCapabilities , mockServerInfo , "Test instructions" );
8471
85- // Use CountDownLatch to coordinate between threads
86- java .util .concurrent .CountDownLatch latch = new java .util .concurrent .CountDownLatch (1 );
87-
8872 // Start initialization with reactive handling
8973 InitializeResult result = asyncMcpClient .initialize ().doOnSubscribe (subscription -> {
9074 // Run in a separate reactive context to avoid blocking the main subscription
@@ -96,17 +80,8 @@ void testSuccessfulInitialization() {
9680 McpSchema .JSONRPCResponse initResponse = new McpSchema .JSONRPCResponse (McpSchema .JSONRPC_VERSION ,
9781 initRequest .id (), mockInitResult , null );
9882 transport .simulateIncomingMessage (initResponse );
99- latch .countDown ();
83+ // latch.countDown();
10084 }).subscribeOn (reactor .core .scheduler .Schedulers .boundedElastic ()).subscribe ();
101- }).doOnTerminate (() -> {
102- try {
103- // Wait for the response simulation to complete
104- latch .await (5 , java .util .concurrent .TimeUnit .SECONDS );
105- }
106- catch (InterruptedException e ) {
107- Thread .currentThread ().interrupt ();
108- throw new RuntimeException ("Interrupted while waiting for initialization" , e );
109- }
11085 }).block ();
11186
11287 // Verify initialized notification was sent
0 commit comments