You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "adityamparikh (via GitHub)" <gi...@apache.org> on 2026/04/24 21:03:07 UTC
[PR] fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics [solr-mcp]
adityamparikh opened a new pull request, #111:
URL: https://github.com/apache/solr-mcp/pull/111
## Summary
- Narrow catch from `RuntimeException` to `SolrException` in `fetchCacheMetrics()` and `fetchHandlerMetrics()`
- Still catches Solr 10 `RemoteSolrException` (subclass of `SolrException`) for graceful degradation when `/admin/mbeans` is unavailable
- Programming bugs (NPE, ClassCastException, etc.) now propagate instead of being silently swallowed
## Test plan
- [x] `./gradlew build` passes
- [x] `./gradlew nativeTest -Pnative` passes (119/119 tests)
- [x] No regressions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics [solr-mcp]
Posted by "adityamparikh (via GitHub)" <gi...@apache.org>.
adityamparikh closed pull request #111: fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics
URL: https://github.com/apache/solr-mcp/pull/111
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics [solr-mcp]
Posted by "adityamparikh (via GitHub)" <gi...@apache.org>.
adityamparikh commented on PR #111:
URL: https://github.com/apache/solr-mcp/pull/111#issuecomment-5341802786
Rebased onto `main` (`a84033b`), with one fix to the PR's own content.
**Fixed:** the diff changed `catch (... | RuntimeException _)` to `catch (... | SolrException e)` — naming a variable that is never used. `main` deliberately uses the unnamed `_` there. Restored to `catch (SolrServerException | IOException | SolrException _)` so the narrowing lands without reintroducing an unused binding.
**One thing worth a reviewer's judgement.** `RemoteSolrException extends SolrException extends RuntimeException`, so the 404 from a removed endpoint is still caught and still degrades to `null` — that part is safe. But `fetchMetrics` also does an unchecked `(NamedList<Object>) response.get("metrics")`. Under the old broad `RuntimeException` catch, a `ClassCastException` from an unexpected `/admin/metrics` response shape would degrade to `null`; after this narrowing it propagates out of `getCollectionStats`.
I think that is the right trade — swallowing `ClassCastException` hides a genuine bug, and surfacing it is the stated point of the PR — but it is a real behaviour change on any Solr whose metrics payload differs from 9.9, which is what our default `solr.test.image` exercises. Happy to add `ClassCastException` back to the catch list if the project would rather keep unconditional graceful degradation there.
Verified: `./gradlew build` green on JDK 25.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics [solr-mcp]
Posted by "adityamparikh (via GitHub)" <gi...@apache.org>.
adityamparikh commented on PR #111:
URL: https://github.com/apache/solr-mcp/pull/111#issuecomment-5357781172
Two updates.
**Added the doc correction this PR invalidates (ab1aa24).** The Solr 10 Compatibility section said
`getCacheMetrics()`/`getHandlerMetrics()` "catch `RuntimeException` (which covers
`RemoteSolrException`)" — untrue the moment this merges, so the fix belongs here rather than
trailing behind. It now also records *why* the narrower catch is correct, which the old wording
didn't. (`CLAUDE.md` is a symlink to `AGENTS.md`, so that's the single source.)
**Resolved a collision with #110.** Both PRs rewrite the same two catch clauses — this one narrows
`RuntimeException` to `SolrException`, #110 was binding the exception for logging while leaving
`RuntimeException` in place. Whichever merged second would have conflicted or silently reverted
the other. #110 now carries the narrowed form too (506f2bb), so the end state is identical in
either merge order and neither blocks the other.
For the record, the narrowing is safe: `RemoteSolrException extends SolrException` in solrj
10.0.0, verified against the jar rather than from memory, so Solr 10's missing `/admin/mbeans`
still degrades to `null`. What stops being swallowed is unrelated runtime failures — which is the
point.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] fix: narrow catch clauses in fetchCacheMetrics/fetchHandlerMetrics [solr-mcp]
Posted by "adityamparikh (via GitHub)" <gi...@apache.org>.
adityamparikh commented on PR #111:
URL: https://github.com/apache/solr-mcp/pull/111#issuecomment-5636229636
Closing: superseded by #110, which merged the same `SolrException` narrowing in both catch clauses. The only remaining piece is the AGENTS.md sentence that still says `RuntimeException`; that one-liner will go in a separate docs fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org