Skip to content

add jspecify nullable annotations on streams Java DSL#2617

Merged
pjfanning merged 4 commits intoapache:mainfrom
pjfanning:jspecify
Apr 8, 2026
Merged

add jspecify nullable annotations on streams Java DSL#2617
pjfanning merged 4 commits intoapache:mainfrom
pjfanning:jspecify

Conversation

@pjfanning
Copy link
Copy Markdown
Member

@pjfanning pjfanning marked this pull request as draft January 10, 2026 14:10
Copy link
Copy Markdown
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Copy Markdown
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition -- JSpecify annotations on the Java DSL will help IDE static analysis and help Java users avoid NPEs.

Observations:

  1. The @Nullable annotations are applied consistently to parameters that can accept null (like rest, those, log parameters). This is correct.

  2. The package-info.java with @NullMarked is the right approach -- it makes the entire Java DSL package null-safe by default, with explicit @Nullable overrides where needed.

  3. JSpecify is added as an Optional dependency, which means it won't be required at runtime. This is correct since the annotations are only needed at compile time.

  4. One thing to consider: this PR only covers the stream Java DSL. The PR description mentions 'probably best to stick with Java DSL only' -- but the actor and other Java DSLs would benefit from the same treatment. Consider filing a follow-up issue for the remaining modules.

No blocking issues.

@pjfanning pjfanning marked this pull request as ready for review April 7, 2026 12:45
@pjfanning
Copy link
Copy Markdown
Member Author

@He-Pin if we don't see any issues caused by this, I'll look into adding similar changes to other modules.

@pjfanning pjfanning merged commit 2b0f6b8 into apache:main Apr 8, 2026
9 checks passed
@pjfanning pjfanning added this to the 2.0.0-M2 milestone Apr 8, 2026
@pjfanning pjfanning deleted the jspecify branch April 8, 2026 19:08
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