Skip to content

Add Suppliers2 and Iterators2 to io.spine.util#953

Merged
alexander-yevsyukov merged 10 commits into
masterfrom
add-suppliers2-and-iterators2
Jul 16, 2026
Merged

Add Suppliers2 and Iterators2 to io.spine.util#953
alexander-yevsyukov merged 10 commits into
masterfrom
add-suppliers2-and-iterators2

Conversation

@alexander-yevsyukov

@alexander-yevsyukov alexander-yevsyukov commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Suppliers2 and Iterators2 were introduced in SpineEventEngine/core-jvm#1656 as @Internal wrappers over Guava's Suppliers.memoize and Iterators.filter. Guava declares those methods as <T extends @Nullable Object> — deliberately, so that null values can flow — but under JSpecify semantics that bound stops T's nullness from being inferred from the assignment, so assigning the result to a non-null type in @NullMarked code reads as a nullness mismatch. Declaring plain <T> in a @NullMarked package binds T to non-null types and settles it.

What changed

  • The two classes now live in io.spine.util (module base) — joining the established Guava-companion family there (Preconditions2, Predicates2). Hosting them at the bottom of the dependency graph shares them SDK-wide and lets core-jvm drop its copies.
  • New Kotlin specs cover both:
    • Suppliers2Spec — the delegate's value is returned; evaluation is lazy and happens exactly once.
    • Iterators2Spec — order-preserving filtering; exhausted iterator when nothing matches; the returned view rejects remove().
    • Both extend UtilityClassTest, inheriting the final-class, private-constructor, and static-method null-hostility checks.
  • The config submodule is updated, and the ErrorProne warnings and the PMD error surfaced by the refreshed toolchain are addressed across pre-existing base and environment sources (Identifier, MessageIdToString, FsObject, ComparisonOperator, ApiOption, TestsProperty, TypeSet, AnyPacker).
  • Javadoc of the new classes is polished per the documentation review: @return tags added to both methods, and the Suppliers.memoize() link is labeled like the Iterators.filter() one.
  • Version: 2.0.0-SNAPSHOT.4242.0.0-SNAPSHOT.425; dependency reports regenerated.

Notes for the reviewer

  • In the regenerated docs/dependencies/pom.xml, the error_prone_annotations entry moved 2.42.02.47.0. This is deterministic generator output — it reflects Guava 33.6.0's requested version, while the classpath resolution still forces 2.42.0 (verified with dependencyInsight); equal values already appear in master's dependencies.md. No dependency pin changed in this PR.
  • Verification at PR-creation HEAD: ./gradlew build dokkaGenerate — green; spine-code-review, kotlin-engineer, and review-docs passes all approved.
  • Follow-up (out of scope here): once this is published, core-jvm can replace its io.spine.server.Suppliers2/Iterators2 with imports from io.spine.util.

🤖 Generated with Claude Code

alexander-yevsyukov and others added 3 commits July 16, 2026 16:59
These `@Internal` utilities wrap Guava's `Suppliers.memoize` and
`Iterators.filter`, whose `<T extends @nullable Object>` bounds read as
nullness mismatches at `@NullMarked` call sites. Declaring plain `<T>`
in the `@NullMarked` package binds `T` to non-null types and settles it.

Both classes come verbatim from SpineEventEngine/core-jvm#1656, which
introduced them under `io.spine.server`. Hosting them here, next to
`Preconditions2` and `Predicates2`, shares them SDK-wide and lets
`core-jvm` drop its copies.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 16, 2026 16:12
@alexander-yevsyukov alexander-yevsyukov self-assigned this Jul 16, 2026
@alexander-yevsyukov alexander-yevsyukov moved this to 🏗 In progress in v2.0 Jul 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Suppliers2 and Iterators2 utility wrappers to io.spine.util (module base) to avoid JSpecify nullness inference issues caused by Guava’s <T extends @Nullable Object> signatures in @NullMarked code, and introduces Kotlin specs to cover the new utilities. It also bumps the snapshot version and regenerates dependency reports accordingly.

Changes:

  • Added io.spine.util.Suppliers2 / io.spine.util.Iterators2 as @Internal Guava-companion utilities.
  • Added Kotlin specs (Suppliers2Spec, Iterators2Spec) extending UtilityClassTest.
  • Bumped versionToPublish to 2.0.0-SNAPSHOT.425 and regenerated dependency report artifacts.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
version.gradle.kts Bumps published snapshot version.
docs/dependencies/pom.xml Regenerated dependency POM reflecting new snapshot + requested dependency versions.
docs/dependencies/dependencies.md Regenerated dependency/license report with updated version and timestamp.
base/src/main/java/io/spine/util/Suppliers2.java Introduces memoizing supplier wrapper (has a type mismatch bug to fix).
base/src/main/java/io/spine/util/Iterators2.java Introduces filtering iterator wrapper (minor signature formatting inconsistency).
base/src/test/kotlin/io/spine/util/Suppliers2Spec.kt Adds tests for lazy, single-evaluation memoization behavior.
base/src/test/kotlin/io/spine/util/Iterators2Spec.kt Adds tests for order-preserving filtering and unsupported removal.
.agents/tasks/add-suppliers2-iterators2.md Agent task tracking file (not reviewed; .agents/** is config-managed in this repo).

Comment thread base/src/main/java/io/spine/util/Suppliers2.java
Comment thread base/src/main/java/io/spine/util/Iterators2.java Outdated
Copilot AI review requested due to automatic review settings July 16, 2026 16:25
@alexander-yevsyukov alexander-yevsyukov moved this from 🏗 In progress to In Review in v2.0 Jul 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.

Keep the return type and the method name on one line, wrapping the
parameter list instead, as `Preconditions2` does. Joining the whole
signature into a single line, as suggested in the PR review, does not
fit the 100-character limit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 16, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Comment thread environment/src/main/java/io/spine/environment/TestsProperty.java
The import became unused when `TestsProperty.TESTS_VALUES` switched to
plain string literals.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 16, 2026 16:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.

@alexander-yevsyukov alexander-yevsyukov merged commit 76b2d00 into master Jul 16, 2026
10 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the add-suppliers2-and-iterators2 branch July 16, 2026 16:42
@github-project-automation github-project-automation Bot moved this from In Review to ✅ Done in v2.0 Jul 16, 2026
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.02%. Comparing base (3c8533f) to head (a517ec2).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #953      +/-   ##
==========================================
- Coverage   94.02%   94.02%   -0.01%     
==========================================
  Files         192      194       +2     
  Lines        4187     4182       -5     
  Branches      345      345              
==========================================
- Hits         3937     3932       -5     
  Misses        149      149              
  Partials      101      101              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants