Skip to content

Add @InjectWireMock as known excluded field annotation#1391

Merged
msridhar merged 2 commits intomasterfrom
InjectWireMock
Dec 22, 2025
Merged

Add @InjectWireMock as known excluded field annotation#1391
msridhar merged 2 commits intomasterfrom
InjectWireMock

Conversation

@msridhar
Copy link
Copy Markdown
Collaborator

@msridhar msridhar commented Dec 22, 2025

Fixes #1390

We stub the annotation since the actual library requires JDK 17 and we still support JDK 11.

Summary by CodeRabbit

  • New Features

    • Added support for WireMock field injection annotation. NullAway now properly recognizes and handles WireMock's injection annotation in nullability analysis, preventing false positives when integrating WireMock with Spring-based applications.
  • Tests

    • Added test coverage for WireMock injection scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@msridhar msridhar requested a review from yuxincs December 22, 2025 16:43
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 22, 2025

Walkthrough

This change adds support for the @InjectWireMock annotation from the WireMock Spring Boot library to NullAway's default excluded field annotations. The annotation is registered in the DEFAULT_EXCLUDED_FIELD_ANNOT set in ErrorProneCLIFlagsConfig, treating fields marked with this annotation as properly initialized. A test annotation definition and corresponding test case verify the functionality, allowing users to utilize the WireMock injection mechanism without requiring null suppression annotations.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding @InjectWireMock to the excluded field annotations list for nullability analysis.
Linked Issues check ✅ Passed The PR fully addresses issue #1390 by adding @InjectWireMock to DEFAULT_EXCLUDED_FIELD_ANNOT and includes test coverage validating the excluded field annotation integration.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective of adding @InjectWireMock support: the annotation stub, the configuration change, and test coverage for the feature.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch InjectWireMock

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c457c76 and d3d9b71.

📒 Files selected for processing (3)
  • nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java
  • nullaway/src/test/java/com/uber/nullaway/FrameworkTests.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/springboot-annotations/InjectWireMock.java
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.
Learnt from: msridhar
Repo: uber/NullAway PR: 1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.
📚 Learning: 2025-08-29T18:41:43.584Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.

Applied to files:

  • nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build caffeine with snapshot
  • GitHub Check: Build and test on macos-latest
  • GitHub Check: Build and test on windows-latest
  • GitHub Check: Build spring-framework with snapshot
  • GitHub Check: Build and test on ubuntu-latest
🔇 Additional comments (3)
nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java (1)

177-188: LGTM! Annotation addition follows established patterns.

The addition of org.wiremock.spring.InjectWireMock to the DEFAULT_EXCLUDED_FIELD_ANNOT set is correctly placed alongside other Spring test framework annotations and follows the existing pattern for dependency injection annotations.

nullaway/src/test/resources/com/uber/nullaway/testdata/springboot-annotations/InjectWireMock.java (1)

1-10: LGTM! Annotation stub is well-defined.

The test annotation stub correctly mimics a runtime injection annotation with appropriate targets (FIELD and PARAMETER) and RUNTIME retention. This is a practical approach to test the functionality without requiring the actual WireMock library that depends on JDK 17.

nullaway/src/test/java/com/uber/nullaway/FrameworkTests.java (1)

434-454: LGTM! Test correctly verifies the new functionality.

The wireMockInjectFieldTest() method properly validates that fields annotated with @InjectWireMock are recognized as initialized by the framework. The test structure is consistent with similar tests like springTestAutowiredFieldTest() and correctly expects no initialization warnings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.19%. Comparing base (c457c76) to head (d3d9b71).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1391   +/-   ##
=========================================
  Coverage     88.19%   88.19%           
  Complexity     2616     2616           
=========================================
  Files            95       95           
  Lines          8675     8675           
  Branches       1743     1743           
=========================================
  Hits           7651     7651           
  Misses          510      510           
  Partials        514      514           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar msridhar enabled auto-merge (squash) December 22, 2025 16:51
@msridhar msridhar merged commit 515134c into master Dec 22, 2025
10 of 11 checks passed
@msridhar msridhar deleted the InjectWireMock branch December 22, 2025 16:52
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.

Add @InjectWireMock to the list of default initializers

2 participants