From 2a0b152c58d417b561d2a45f8e793b775c34da04 Mon Sep 17 00:00:00 2001 From: adityamparikh Date: Fri, 24 Apr 2026 14:04:19 -0400 Subject: [PATCH] fix: narrow SchemaService.getSchema() throws clause Change getSchema() from `throws Exception` to `throws SolrServerException, IOException` to match the actual exceptions thrown by SchemaRequest.process(). Signed-off-by: Aditya Parikh Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: adityamparikh --- .../apache/solr/mcp/server/schema/SchemaService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/solr/mcp/server/schema/SchemaService.java b/src/main/java/org/apache/solr/mcp/server/schema/SchemaService.java index 8e0549a1..d46343ab 100644 --- a/src/main/java/org/apache/solr/mcp/server/schema/SchemaService.java +++ b/src/main/java/org/apache/solr/mcp/server/schema/SchemaService.java @@ -261,9 +261,11 @@ public String getSchemaResource(String collection) { * the name of the Solr collection to retrieve schema information for * @return complete schema representation containing all field and type * definitions - * @throws Exception - * if collection does not exist, access is denied, or communication - * fails + * @throws SolrServerException + * if the Solr server returns an error or the collection does not + * exist + * @throws IOException + * if communication with the Solr server fails * @see SchemaRepresentation * @see SchemaRequest * @see org.apache.solr.client.solrj.response.schema.SchemaResponse @@ -273,7 +275,7 @@ public String getSchemaResource(String collection) { name = "get-schema", annotations = @McpTool.McpAnnotations(readOnlyHint = true), description = "Get schema for a Solr collection") - public SchemaRepresentation getSchema(String collection) throws Exception { + public SchemaRepresentation getSchema(String collection) throws SolrServerException, IOException { SchemaRequest schemaRequest = new SchemaRequest(); return schemaRequest.process(solrClient, collection).getSchemaRepresentation(); }