Skip to content

Re-land the Kotlin function arity rework (#1278) on main - #8

Draft
apoupard wants to merge 7 commits into
mainfrom
feat/kotlin-arity-relanding
Draft

apoupard wants to merge 7 commits into
mainfrom
feat/kotlin-arity-relanding

Conversation

@apoupard

@apoupard apoupard commented Oct 1, 2026 •

Copy link
Copy Markdown

Re-lands the Kotlin function arity rework from spring-cloud#1278 on top of current main.

Why

spring-cloud#1278 was "squashed and merged" upstream as 62d73bf9b on 2025-06-20, but that commit sits on a line of history that was later dropped from main: no upstream branch (main, 5.0.x, 4.3.x) and no release (v4.3.1–v4.3.3, v5.0.0–v5.0.4) contains it. Upstream still detects Kotlin lambdas with KotlinLambdaToFunctionAutoConfiguration's exact-arity check, which is why F2 has to carry the arity patch on its vendored copy (fixers/5.0.4, #7). With this rework in, that patch can go.

Commits

  1. The six original Fixes: Enhance Kotlin Support for Suppliers, Functions, and Consumers #1277 spring-cloud/spring-cloud-function#1278 commits, cherry-picked unchanged (authors and dates kept): 029fc7444 arity tests, a8b0f891f arity handling, 5c917a584 unit tests, 76537c10a docs, 6dfc8ee6a TypeUtils → KotlinUtils, 50b8929fb FunctionUtils → KotlinUtils. Same 60 files and identical content as the upstream squash 62d73bf9b. Only conflict (in the arity-handling commit): KotlinLambdaToFunctionAutoConfiguration is deleted by the rework but was edited on main since (Function post processing doesn't work with Kotlin classes spring-cloud/spring-cloud-function#1300 post-processing, license header) → resolved as delete, Function post processing doesn't work with Kotlin classes spring-cloud/spring-cloud-function#1300 ported in the last commit.
  2. b30982b87: adaptations to current main
    • Function post processing doesn't work with Kotlin classes spring-cloud/spring-cloud-function#1300 post-processing: KotlinFunctionWrapper.getKotlinLambdaTarget(), implemented by all 15 Kotlin wrappers; SimpleFunctionRegistry and ContextFunctionCatalogAutoConfigurationKotlinTests use it instead of the removed KotlinLambdaToFunctionAutoConfiguration.KotlinFunctionWrapper.
    • Flow input/output types: the non-suspend Flow wrappers (FlowToPlain, FlowToFlow, ConsumerFlow, SupplierFlow) declared Flux<Flow<T>>; they now declare Flux<T> via KotlinUtils.getFlowTypeArguments, like the suspend wrappers. In June a failed element conversion silently fell back to the raw value; with main's stricter JSON conversion (fix(context): propagate JSON deserialization error instead of silent ClassCastException spring-cloud/spring-cloud-function#1429) it surfaced as 500 / wrong body in KotlinFunctionArityBeanTest.testFunctionFlowToPlain / testFunctionFlowToFlow.
    • Reactor nullness: CoroutinesUtils generic outputs bounded to Any (Flux<T : Any>).
    • Boot 4: AutoConfigureWebTestClient moved to org.springframework.boot.webtestclient.autoconfigure.
    • Checkstyle: 20xx-present license headers on the new files, import order.

Verification

./mvnw -pl spring-cloud-function-context,spring-cloud-function-kotlin -am test, all green, no flakes:

module tests
spring-cloud-function-context 232 (13 skipped)
spring-cloud-function-web 199 (25 skipped)
spring-cloud-function-adapter-aws 55
spring-cloud-function-kotlin 368 (incl. the arity suites from spring-cloud#1278)

@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

Adrien and others added 7 commits October 1, 2026 21:42
This commit introduces a comprehensive suite of tests to cover all possible declarations of Kotlin functions, consumers, and suppliers within the `spring-cloud-function-kotlin` module.

The primary goal of these tests is to explore the various declaration combinations and identify potential areas for improvement and enhanced support in the framework.

Signed-off-by: Adrien Poupard <adrien@komune.io>
This commit refactors the `spring-cloud-function-context` to comprehensively handle all combinations of possible declarations for Kotlin functions, consumers, and suppliers. This improves the framework's ability to correctly interpret and manage different Kotlin functional styles.

Signed-off-by: Adrien Poupard <adrien@komune.io>
This commit adds new unit tests to verify the core logic for Kotlin arity handling and wrapper mechanisms. These tests cover various scenarios including catalogue registration and native type casting for consumers, functions, and suppliers.

Signed-off-by: Adrien Poupard <adrien@komune.io>
Signed-off-by: Adrien Poupard <adrien@komune.io>
… Kotlin type handling and consistency.

Signed-off-by: Adrien Poupard <adrien@komune.io>
…ction validation

Signed-off-by: Adrien Poupard <adrien@komune.io>
- Port spring-cloudGH-1300 post-processing: KotlinFunctionWrapper exposes getKotlinLambdaTarget(), implemented by every Kotlin wrapper; SimpleFunctionRegistry and the Kotlin catalog test use it instead of the removed KotlinLambdaToFunctionAutoConfiguration.KotlinFunctionWrapper.
- Non-suspend Flow wrappers declare Flux<T> instead of Flux<Flow<T>> (unwrap with KotlinUtils.getFlowTypeArguments, as the suspend wrappers do); with the stricter JSON conversion on main the old type made Flow inputs fail with 500.
- CoroutinesUtils: bound generic outputs to Any, required by Reactor's nullness annotations (Flux<T : Any>).
- Boot 4: AutoConfigureWebTestClient moved to org.springframework.boot.webtestclient.autoconfigure.
- License headers to the 20xx-present format and import order, for checkstyle.
@apoupard
apoupard force-pushed the feat/kotlin-arity-relanding branch from 5779a92 to b30982b Compare October 1, 2026 19:42
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.

1 participant