Add Suppliers2 and Iterators2 to io.spine.util#953
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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.Iterators2as@InternalGuava-companion utilities. - Added Kotlin specs (
Suppliers2Spec,Iterators2Spec) extendingUtilityClassTest. - Bumped
versionToPublishto2.0.0-SNAPSHOT.425and 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). |
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>
The import became unused when `TestsProperty.TESTS_VALUES` switched to plain string literals. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
armiol
approved these changes
Jul 16, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suppliers2andIterators2were introduced in SpineEventEngine/core-jvm#1656 as@Internalwrappers over Guava'sSuppliers.memoizeandIterators.filter. Guava declares those methods as<T extends @Nullable Object>— deliberately, so thatnullvalues can flow — but under JSpecify semantics that bound stopsT's nullness from being inferred from the assignment, so assigning the result to a non-null type in@NullMarkedcode reads as a nullness mismatch. Declaring plain<T>in a@NullMarkedpackage bindsTto non-null types and settles it.What changed
io.spine.util(modulebase) — joining the established Guava-companion family there (Preconditions2,Predicates2). Hosting them at the bottom of the dependency graph shares them SDK-wide and letscore-jvmdrop its copies.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 rejectsremove().UtilityClassTest, inheriting the final-class, private-constructor, and static-method null-hostility checks.configsubmodule is updated, and theErrorPronewarnings and the PMD error surfaced by the refreshed toolchain are addressed across pre-existingbaseandenvironmentsources (Identifier,MessageIdToString,FsObject,ComparisonOperator,ApiOption,TestsProperty,TypeSet,AnyPacker).@returntags added to both methods, and theSuppliers.memoize()link is labeled like theIterators.filter()one.2.0.0-SNAPSHOT.424→2.0.0-SNAPSHOT.425; dependency reports regenerated.Notes for the reviewer
docs/dependencies/pom.xml, theerror_prone_annotationsentry moved2.42.0→2.47.0. This is deterministic generator output — it reflects Guava 33.6.0's requested version, while the classpath resolution still forces2.42.0(verified withdependencyInsight); equal values already appear in master'sdependencies.md. No dependency pin changed in this PR../gradlew build dokkaGenerate— green;spine-code-review,kotlin-engineer, andreview-docspasses all approved.core-jvmcan replace itsio.spine.server.Suppliers2/Iterators2with imports fromio.spine.util.🤖 Generated with Claude Code