diff --git a/AGENTS.md b/AGENTS.md index 7d7ce524..325ab1c7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -339,9 +339,11 @@ The Solr Docker image used in tests is configurable via the `solr.test.image` sy ### Solr 10 Compatibility Solr 10.0.0 is fully supported with the JSON wire format. The `/admin/mbeans` endpoint was -removed in Solr 10; `getCacheMetrics()` and `getHandlerMetrics()` now catch `RuntimeException` -(which covers `RemoteSolrException`) so they degrade gracefully and return `null`. Tests that -check `cacheStats` and `handlerStats` already handle `null` values. +removed in Solr 10; `getCacheMetrics()` and `getHandlerMetrics()` catch `SolrException` (which +`RemoteSolrException` extends) so they degrade gracefully and return `null`. Tests that check +`cacheStats` and `handlerStats` already handle `null` values. The catch is deliberately *not* +`RuntimeException`: an unrelated runtime failure inside metrics parsing should surface as a bug, +not be silently reported as "metrics unavailable". Remaining known differences from Solr 9: - **`/admin/mbeans` removed:** Cache and handler stats from `getCollectionStats()` will always be `null` on Solr 10. A future migration to `/admin/metrics` will restore these metrics. diff --git a/src/main/java/org/apache/solr/mcp/server/collection/CollectionService.java b/src/main/java/org/apache/solr/mcp/server/collection/CollectionService.java index 011d278e..2860c9fa 100644 --- a/src/main/java/org/apache/solr/mcp/server/collection/CollectionService.java +++ b/src/main/java/org/apache/solr/mcp/server/collection/CollectionService.java @@ -40,6 +40,7 @@ import org.apache.solr.client.solrj.response.LukeResponse; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.SolrPingResponse; +import org.apache.solr.common.SolrException; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.mcp.server.config.SolrConfigurationProperties; @@ -692,7 +693,7 @@ public QueryStats buildQueryStats(QueryResponse response) { CacheStats stats = extractCacheStats(coreMetrics); return isCacheStatsEmpty(stats) ? null : stats; - } catch (SolrServerException | IOException | RuntimeException _) { + } catch (SolrServerException | IOException | SolrException _) { return null; } } @@ -810,7 +811,7 @@ private CacheStats extractCacheStats(NamedList coreMetrics) { HandlerStats stats = new HandlerStats(selectHandler, updateHandler); return isHandlerStatsEmpty(stats) ? null : stats; - } catch (SolrServerException | IOException | RuntimeException _) { + } catch (SolrServerException | IOException | SolrException _) { return null; } }