fix: SqlCapture captures an action that returns no row - #490
Merged
Conversation
The result type of execute and executeThrowing was a bare <T> in a @NullMarked package, so Kotlin read it as T : Any and a capture whose action ends in a lookup that finds nothing did not compile: val genre = capture.execute { genreRepository.findByName("Sci-Fi") } Both now declare T extends @nullable Object, the treatment the rest of the null-marked surface already gives a type parameter that admits a nullable argument. Strict JSpecify enforcement starts at Kotlin 2.1, which the reactor's own Kotlin 2.0 modules never exercise, and storm-test's tests are written in Java, where a non-null type parameter compiles regardless, so the Kotlin 2.4 smoke projects gain a case that compiles both calls.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
SqlCapture.executeandexecuteThrowingdeclared a bare<T>in a@NullMarkedpackage, so Kotlin reads the result type asT : Any. A capture whose action ends in a lookup that finds nothing — the ordinary case in a test — does not compile:Both now declare
T extends @Nullable Object, the treatment the rest of the null-marked surface already gives a type parameter that admits a nullable argument (TypedMetamodel,AbstractMetamodel,Instantiator,Metamodel.getValue). The 1.14.0 changelog entry that lists those is extended with these two.There is no workaround worth having on the caller's side: capturing a nullable lookup means declaring a
varahead of the block and assigning into it fromrecord { }, which is exactly the shapeexecuteexists to avoid.Why it was not caught
Two gaps line up. Strict JSpecify enforcement starts at Kotlin 2.1, which the reactor's own Kotlin 2.0 modules never exercise, and storm-test's own tests are written in Java, where a non-null type parameter compiles regardless of the annotation. So the Kotlin 2.4 smoke projects — the surface the changelog already names as the guard for this — gain a case that compiles both calls against a nullable-returning action.
The guard was verified in both directions: it fails against a storm-test built without the fix, with the same diagnostic quoted above, and passes with it.
Notes
SqlInterceptorManager.Scope.get/callcarry the same bare<T>one level down. They are internal and reached only from Java today, so they are left alone; a Kotlin caller inside Storm would hit the same wall.Found while migrating the five
storm-example-*repositories to 1.14.0, wherecapture.execute { … }on a nullable repository lookup stopped compiling.