adityamparikh opened a new pull request, #332:
URL: https://github.com/apache/solr-mcp/pull/332

   ## Summary
   
   An Effective Modern Java pass over the whole repo on its Java 25 baseline 
(`java.toolchain.languageVersion = 25`; no `options.release`, no 
`--enable-preview`). It makes two bug fixes, two cleanups and two idiom sweeps, 
in six commits that each revert on their own.
   
   ```diff
    // schema/SchemaService.java — one of 34 converted chains; the value is 
unchanged
          description =
   -          "Get the full schema definition of a Solr collection: field types 
with their "
   -              + "analyzers, declared fields, dynamic-field patterns (such 
as *_s) and copy fields. "
   -              + ...
   -              + "choose fields for search, call list-fields instead.")
   +          """
   +          Get the full schema definition of a Solr collection: field types 
with their \
   +          analyzers, declared fields, dynamic-field patterns (such as *_s) 
and copy fields. \
   +          ...
   +          choose fields for search, call list-fields instead.""")
   
    // indexing/IndexingServiceIntegrationTest.java — one of 23 instanceof sites
   -    if (nameValue instanceof List) {
   -      assertEquals("Test Book 1", ((List<?>) nameValue).getFirst());
   +    if (nameValue instanceof List<?> nameValues) {
   +      assertEquals("Test Book 1", nameValues.getFirst());
   ```
   
   ### Bugs fixed
   
   1. **`config/SolrConfigurationProperties.java`: the record's generated 
`toString()` printed `solr.password` in clear text.** Anything that logged the 
bound properties, or showed them in a debugger or a failure message, exposed 
the Basic Auth credential. It now prints `password=******` when a password is 
set and `password=null` when none is. Two tests cover this.
   2. **`collection/CollectionService.java` (`completeCollection`): a swallowed 
exception.** A `SolrServerException` or `IOException` was dropped with no log, 
so a Solr outage looked like an empty cluster to completion clients. The method 
still returns no suggestions, and now logs the cause at `debug`.
   
   ### Cleanups
   
   3. **`indexing/IndexingService.java`:** `toLowerCase(Locale.ROOT)` instead 
of the default-locale `toLowerCase()`, matching the rest of the codebase.
   4. **`collection/CollectionUtils.java`:** now `final`, like the other static 
utility classes `PromptText` and `FieldFlags`.
   
   ### Idiom sweeps
   
   5. **Text blocks for wrapped string literals.** There are 34 literal-only 
`+` chains: 27 in `src/main` (the `@McpTool`/`@McpToolParam` descriptions in 
`SchemaService`, `SearchService`, `CollectionService`, `IndexingService` and 
`AliasService`, plus their hint and error constants) and 7 in tests. This makes 
the tool descriptions consistent with the `search` description and the prompt 
bodies, which already use text blocks. These strings are single-line prose 
wrapped to fit the line length, so each line ends in `\`, the space that began 
a piece moves before it, and the closing `"""` sits on the last content line. 
No newline is added. Concatenations that mix in variables, such as 
`"Successfully indexed " + count + …`, are left alone.
   6. **`instanceof` patterns.** 23 `instanceof`-then-cast checks in 
`IndexingServiceIntegrationTest` and `SearchServiceIntegrationTest` now use `x 
instanceof List<?> xValues` (or `Number n`). This removes the local variables 
that only re-cast the checked value.
   
   ### Suggested follow-ups (contract changes, not made here)
   
   - `AliasResult` uses `java.util.Date` where the other result records use 
`Instant`. Changing it alters the JSON wire format.
   - `checkHealth` returns `e.getMessage()` to the client, while other tools 
deliberately withhold Solr failure text.
   - Result builders call `Instant.now()` directly. An injected `Clock` would 
make the timestamps testable.
   
   ## Evidence
   
   **The strings are unchanged.** The conversion script wrote every original 
chain and its text block into one standalone class, `check("<file>:<line>", 
"<original>" + "<…>", """<text block>""")`. `javac` evaluated both forms of all 
34 and compared them:
   
   ```text
   $ java TextBlockCheck.java
   ALL 34 IDENTICAL
   ```
   
   The one block re-wrapped by hand afterwards (`list-fields`, to fix an 
orphaned `this before` line in the original) was checked the same way against 
`upstream/main`, and is `IDENTICAL`. The check catches mistakes: in the same 
harness, dropping a single trailing `\` reports `CHANGED`.
   
   **The password redaction**, for `new 
SolrConfigurationProperties("http://localhost:8983/solr/";, "solr", "s3cr3t")`:
   
   ```text
   before: SolrConfigurationProperties[url=http://localhost:8983/solr/, 
username=solr, password=s3cr3t]
   after:  SolrConfigurationProperties[url=http://localhost:8983/solr/, 
username=solr, password=******]
   ```
   
   | | `./gradlew build` |
   |---|---|
   | This branch | BUILD_RESULT_PLACEHOLDER |
   
   ## Merge Danger
   
   **Door:** two-way. Each commit reverts on its own.
   
   **Blast Radius:** minimal
   
   - **Breaks callers' compilation:** no. No public signature changed.
   - **Runtime behavior changes:** `SolrConfigurationProperties.toString()` 
masks the password, and a failed collection-name completion now logs at 
`debug`. No MCP-visible text changes.
   - **Overlap with open PRs:** the text-block commit edits the same `@McpTool` 
descriptions in the four services as several open typed-contracts PRs, 
including #307 and #320. Whichever side merges second has a mechanical rebase.
   
   🤖 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to