Skip to content

Commit cf5468a

Browse files
authored
Update ResponseSubscribers.java
sink.must() must be executed, otherwise in the case of empty return (such as notify), the deliveredSink of sendMessage will not be able to process the stream correctly, resulting in Client failed to initialize by explicit API call
1 parent bf2c8c9 commit cf5468a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mcp/src/main/java/io/modelcontextprotocol/client/transport/ResponseSubscribers.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ protected void hookOnNext(String line) {
237237

238238
@Override
239239
protected void hookOnComplete() {
240-
if (this.eventBuilder.length() > 0) {
241-
String data = this.eventBuilder.toString();
242-
this.sink.next(new AggregateResponseEvent(responseInfo, data));
243-
}
240+
// sink.next() is must
241+
String data = this.eventBuilder.toString();
242+
this.sink.next(new AggregateResponseEvent(responseInfo, data));
243+
244244
this.sink.complete();
245245
}
246246

0 commit comments

Comments
 (0)