File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
mcp-core/src/main/java/io/modelcontextprotocol/server Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -645,13 +645,10 @@ private McpRequestHandler<McpSchema.ReadResourceResult> resourcesReadRequestHand
645
645
new TypeRef <McpSchema .ReadResourceRequest >() {
646
646
});
647
647
var resourceUri = resourceRequest .uri ();
648
-
649
- Optional <McpServerFeatures .AsyncResourceSpecification > specification = asyncResourceSpecification (
650
- resourceUri );
651
- if (specification .isPresent ()) {
652
- return Mono .error (RESOURCE_NOT_FOUND .apply (resourceUri ));
653
- }
654
- return Mono .defer (() -> specification .get ().readHandler ().apply (exchange , resourceRequest ));
648
+ return asyncResourceSpecification (resourceUri )
649
+ .map (asyncResourceSpecification -> Mono
650
+ .defer (() -> asyncResourceSpecification .readHandler ().apply (exchange , resourceRequest )))
651
+ .orElseGet (() -> Mono .error (RESOURCE_NOT_FOUND .apply (resourceUri )));
655
652
};
656
653
}
657
654
Original file line number Diff line number Diff line change @@ -488,7 +488,8 @@ private McpStatelessRequestHandler<McpSchema.ReadResourceResult> resourcesReadRe
488
488
};
489
489
}
490
490
491
- private Optional <McpStatelessServerFeatures .AsyncResourceSpecification > asyncResourceSpecification (String resourceUri ) {
491
+ private Optional <McpStatelessServerFeatures .AsyncResourceSpecification > asyncResourceSpecification (
492
+ String resourceUri ) {
492
493
return resources .values ()
493
494
.stream ()
494
495
.filter (resourceSpecification -> this .uriTemplateManagerFactory
You can’t perform that action at this time.
0 commit comments