[BUG] Re-subscribing the Mono returned by listTools/listResources/listResourceTemplates/listPrompts/listRoots duplicates the results
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Tìm năm phương thức được liệt kê: McpAsyncServerExchange#listRoots() và McpAsyncClient#listTools(), listResources(), listResourceTemplates(), listPrompts(). Đọc các lời gọi reduce(seed, accumulator) của chúng và fixture kiểm thử hiện có cho một phiên được mô phỏng trả về hai roots; xác minh mỗi lần đăng ký đều trả về cùng kết quả. Hoàn tất khi cả năm phương thức tạo một bộ tích lũy mới cho mỗi lần đăng ký và các kiểm thử bao phủ những lần đăng ký lặp lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug description
The Mono returned by these methods is not safe to subscribe more than once: each
subscription appends to the same mutable accumulator created when the method was called,
so the results grow on every subscription.
Mono<McpSchema.ListRootsResult> listRoots = exchange.listRoots();
listRoots.block().roots().size(); // 2
listRoots.block().roots().size(); // 4 <- duplicated
listRoots.block().roots().size(); // 6
Affected methods (all use reduce(seed, accumulator) with a seed created at assembly
time):
McpAsyncServerExchange#listRoots()McpAsyncClient#listTools()McpAsyncClient#listResources()McpAsyncClient#listResourceTemplates()McpAsyncClient#listPrompts()
Steps to reproduce
Using the existing test fixture (McpAsyncServerExchange with a mocked session that
returns a single page of 2 roots):
Mono<McpSchema.ListRootsResult> listRoots = exchange.listRoots();
System.out.println(listRoots.block().roots().size()); // 2
System.out.println(listRoots.block().roots().size()); // 4
System.out.println(listRoots.block().roots().size()); // 6
Expected behavior
Every subscription starts from an empty accumulator and returns the same result (2 / 2 /
2). Re-subscribing a Mono is a supported Reactor pattern (retry, repeat, cache, reusing
the Mono in several downstream branches), and concurrent subscriptions currently race on
the shared ArrayList too.
Suggested fix
Flux#reduceWith(Supplier, BiFunction) creates the seed per subscription:
.reduceWith(() -> McpSchema.ListRootsResult.builder(new ArrayList<>()).build(),
(allRootsResult, result) -> { ... })
.reduceWith(ArrayList<McpSchema.Tool>::new, (accumulated, result) -> { ... })
Happy to open a PR with the five call sites updated and tests if you agree with the
approach.
- Ngôn ngữ chính
- Java
- Star
- 3.7k
- Fork
- 1.2k
- Merge trung bình
- 3 giờ 38 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/java-sdk
-
HttpServletStreamableServerTransportProvider: GET stream sends no status or headers until the first eventCó thể đã có người làm @karthiksenv đã nhận 9 ngày trước. Đang mởarea/server area/transport P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
modelcontextprotocol/java-sdk#1155 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Client request handlers that complete empty send no JSON-RPC responseCó thể đã có người làm @1fanwang đã nhận 38 ngày trước. Đang mởarea/client bug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
modelcontextprotocol/java-sdk#1124 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilitiesCó thể đã có người làm @1yuxiangJ đã nhận 54 ngày trước. Đang mởbug P2 ready for work
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/java-sdk#1086 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Reject listRoots if not supported by client, without sending any requestCó thể đã có người làm @nikita-kibitkin đã nhận 77 ngày trước. Đang mởenhancement good first issue P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
modelcontextprotocol/java-sdk#1067 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
StdioClientTransport missing explicit UTF-8 charset in InputStreamReader (same issue as #295, but on client side)Có thể đã có người làm @suryateja-g13 đã nhận 148 ngày trước. Đang mởbug P2 ready for work
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
modelcontextprotocol/java-sdk#898 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của modelcontextprotocol/java-sdk
Issue tương tự
-
module: core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
bigbluebutton/bigbluebutton#26028 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix SNMP4J Agent vulnerabilityĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
MetricsHub/metricshub-community#1390 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
apache/rocketmq-dashboard#6331 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Upgrade to Commons Codec 1.23.0Đang mởstatus: team-only type: dependency-upgrade
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
spring-projects/spring-boot#52143 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/frontend good first issue kind/cooldown
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kestra-io/kestra#20704 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày