fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics - #111
fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics#111adityamparikh wants to merge 2 commits into
Conversation
02a0b4a to
521eb2f
Compare
On Solr 10 the /admin/mbeans endpoint was removed, so get-collection-stats degrades gracefully and returns null cacheStats/handlerStats. Nothing on the tool surface said so, leaving MCP clients to treat the nulls as a failure and retry or misreport. State the behavior in the tool description, which every client reads. Kept to the description only to avoid colliding with PR #111, which touches the fetchCacheMetrics/fetchHandlerMetrics implementations. Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Change catch from RuntimeException to SolrException in fetchCacheMetrics() and fetchHandlerMetrics(). This still catches Solr 10's RemoteSolrException (subclass of SolrException) for graceful degradation when /admin/mbeans is unavailable, but no longer swallows programming bugs like NPE or ClassCastException. Closes #4 Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
521eb2f to
3df481e
Compare
|
Rebased onto Fixed: the diff changed One thing worth a reviewer's judgement. I think that is the right trade — swallowing Verified: |
Adopts the narrowing from apache#111 so the two PRs compose instead of colliding. Both PRs rewrite the same two catch clauses in fetchCacheMetrics and fetchHandlerMetrics. apache#111 narrows RuntimeException to SolrException; this PR was binding the exception for logging while leaving RuntimeException in place. Whichever merged second would either conflict or silently revert the other's intent — so this branch now carries the narrowed form too, and the end state is the same in either merge order. RemoteSolrException extends SolrException (verified against solrj 10.0.0), so the Solr 10 path where /admin/mbeans is gone still degrades to null rather than propagating. What no longer gets swallowed is unrelated RuntimeExceptions -- which is the point of apache#111, and is what the new debug logging is there to surface. Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
The Solr 10 Compatibility section said getCacheMetrics()/getHandlerMetrics() "catch RuntimeException (which covers RemoteSolrException)". This PR is what makes that untrue, so the correction belongs here rather than trailing behind in a follow-up. Also records why the narrower catch is the right one: RemoteSolrException extends SolrException, so Solr 10's missing /admin/mbeans still degrades to null, while an unrelated runtime failure in metrics parsing now surfaces as a bug instead of masquerading as "metrics unavailable". Note CLAUDE.md is a symlink to AGENTS.md, so this is the single source. Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
|
Two updates. Added the doc correction this PR invalidates (ab1aa24). The Solr 10 Compatibility section said Resolved a collision with #110. Both PRs rewrite the same two catch clauses — this one narrows For the record, the narrowing is safe: |
Summary
RuntimeExceptiontoSolrExceptioninfetchCacheMetrics()andfetchHandlerMetrics()RemoteSolrException(subclass ofSolrException) for graceful degradation when/admin/mbeansis unavailableTest plan
./gradlew buildpasses./gradlew nativeTest -Pnativepasses (119/119 tests)🤖 Generated with Claude Code