Skip to content

fix: add JSpecify @Nullable annotations for accurate null contracts#115

Closed
adityamparikh wants to merge 7 commits into
apache:mainfrom
adityamparikh:fix/jspecify-nullable-annotations
Closed

fix: add JSpecify @Nullable annotations for accurate null contracts#115
adityamparikh wants to merge 7 commits into
apache:mainfrom
adityamparikh:fix/jspecify-nullable-annotations

Conversation

@adityamparikh
Copy link
Copy Markdown
Contributor

Summary

  • Add @Nullable annotations from JSpecify to all locations where null is a legitimate value
  • Fixes the mismatch between the @NullMarked package declaration and actual null usage
  • Enables NullAway to accurately detect null-safety violations
  • Covers DTOs, service return types, and utility method signatures

Test plan

  • ./gradlew build passes (including NullAway checks)
  • ./gradlew nativeTest -Pnative passes (119/119 tests)
  • No regressions

🤖 Generated with Claude Code

adityamparikh and others added 6 commits April 24, 2026 11:12
Add @nullable annotations from org.jspecify.annotations to all locations
where null is a legitimate value, fixing the mismatch between the
@NullMarked package declaration and actual null usage. This enables
NullAway to accurately detect null-safety violations.

Annotated locations:
- Dtos.java: SolrMetrics (cacheStats, handlerStats), IndexStats
  (segmentCount), QueryStats (maxScore), CacheStats (all caches),
  HandlerStats (both handlers), HandlerInfo (errors, timeouts,
  totalTime, avgTimePerRequest, avgRequestsPerSecond),
  SolrHealthStatus (errorMessage, responseTime, totalDocuments,
  solrVersion, status)
- CollectionService.java: getCacheMetrics(), getHandlerMetrics(),
  fetchCacheMetrics(), fetchHandlerMetrics(), fetchMetrics(),
  fetchFlatHandlerInfo(), extractFlatHandlerInfo(),
  extractSingleCacheInfo(), extractCollectionName(),
  createCollection() optional parameters
- CollectionUtils.java: getLong(), getFloat(), getInteger() return types
- SearchResponse.java: maxScore
- SearchService.java: search() optional parameters

Closes #6

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
@epugh
Copy link
Copy Markdown
Contributor

epugh commented May 2, 2026

@adityamparikh I updated this PR for the new ci integration tests... We may want to think about if our integration tests are reliable to run as part of ci. Can you assess if the failure is related to this PR or a flaky test and something we need to harden. If tests are flaky, we probably don't want to add then to CI, they may offer more frustration than value!

The JDK 25 HttpClient's HTTP/2 transport intermittently closes
reused connections with java.io.EOFException against Solr/Jetty,
causing test flakiness (observed in
SearchServiceIntegrationTest.testSpecialCharactersInQuery on CI).

HTTP/2 multiplexing is not needed for our usage; force HTTP/1.1
on HttpJdkSolrClient via useHttp1_1(true) for deterministic
behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
@adityamparikh
Copy link
Copy Markdown
Contributor Author

Closing as superseded by #133, which is a strict superset for the JSpecify rollout: all Dtos.java, CollectionUtils.get{Long,Float,Integer}, CollectionService cache/handler return types, and JsonResponseParser.convertValue annotations from this PR are included there, along with @NullMarked package-info for every sub-package.

Note: the SolrConfig#useHttp1_1(true) change in this PR is an unrelated HTTP wire-protocol fix and is not in #133. If we still want it, it should land as its own focused PR rather than ride along with the JSpecify rollout.

@adityamparikh
Copy link
Copy Markdown
Contributor Author

Correction to my previous note: the useHttp1_1(true) change landed separately via #130 (commit 62e92cd) and is already on main. So this PR is fully subsumed by #133 — nothing left to extract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants