Skip to content

Commit 9224e8e

Browse files
adityamparikhclaude
andcommitted
fix(collection): catch RuntimeException from removed /admin/mbeans in Solr 10
SolrInfoMBeanHandler (and thus the /admin/mbeans endpoint) was removed in Solr 10. When getCacheMetrics() or getHandlerMetrics() call this endpoint on a Solr 10 server, SolrJ throws RemoteSolrException (a RuntimeException) because the server returns an HTML 404 page instead of JSON. Widen the catch in both methods to include RuntimeException so the server degrades gracefully (returning null for cache/handler stats) rather than propagating the exception. The integration tests already handle null stats, so all tests now pass with solr:10-slim. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
1 parent 4b08938 commit 9224e8e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/org/apache/solr/mcp/server/metadata/CollectionService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,9 @@ public CacheStats getCacheMetrics(String collection) {
609609
}
610610

611611
return stats;
612-
} catch (SolrServerException | IOException e) {
612+
} catch (SolrServerException | IOException | RuntimeException e) {
613+
// RuntimeException covers SolrException subclasses (e.g. RemoteSolrException)
614+
// thrown when the /admin/mbeans endpoint is unavailable (removed in Solr 10).
613615
return null; // Return null instead of empty object
614616
}
615617
}
@@ -781,7 +783,9 @@ public HandlerStats getHandlerMetrics(String collection) {
781783
}
782784

783785
return stats;
784-
} catch (SolrServerException | IOException e) {
786+
} catch (SolrServerException | IOException | RuntimeException e) {
787+
// RuntimeException covers SolrException subclasses (e.g. RemoteSolrException)
788+
// thrown when the /admin/mbeans endpoint is unavailable (removed in Solr 10).
785789
return null; // Return null instead of empty object
786790
}
787791
}

0 commit comments

Comments
 (0)