Kotlin function wrapper treats empty input as no input

オープン
#1,537 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@seonwooj0810 がすでに取り組んでいます。

2026年11月24日 から。

  • #1549 @seonwooj0810 による — オープン

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
java, kotlin, spring
領域
backend

調査の方向性

Start in the spring-cloud-function-kotlin module at KotlinLambdaToFunctionAutoConfiguration, focusing on KotlinFunctionWrapper.apply, getFunctionRegistration and isTypeRepresentedByClass. Read the existing Kotlin function tests to see how a (String) -> String function is registered, then change the empty check to input == null and add tests for empty string, collection, map, array and Optional, plus the suffix and Function1/Function10 cases. Done means the module tests pass and empty inputs reach the function instead of throwing ClassCastException.

索引モデルが issue の本文から書いたものです。

説明

5.0.x backport bug

KotlinLambdaToFunctionAutoConfiguration.KotlinFunctionWrapper.apply(Object) decides between calling the function with an argument and without one using ObjectUtils.isEmpty(input). That is also true for an empty String, an empty collection, an empty map, an empty array and an empty Optional, which are valid inputs.

For a Kotlin function of one argument (for example (String) -> String) invoked with "", the wrapper calls invoke() without an argument. That method checks for a Function0 or a suspending supplier and otherwise casts the target to java.util.function.Supplier, which a Kotlin lambda is not, so the call fails with ClassCastException instead of invoking the function with the empty value.

The check should be input == null.

Other problems in the same class:

  • getFunctionRegistration(..) casts the discovered function type to ParameterizedType without checking it, which fails with NullPointerException or ClassCastException if the type can not be determined
  • the bean name suffix is removed with replace(SUFFIX, ""), which removes every occurrence rather than only a trailing one
  • isTypeRepresentedByClass uses getTypeName().contains("kotlin.jvm.functions.Function1"), which also matches Function10 to Function19 (and Function2 matches Function20 to Function22)

There are no tests for this class in the module. Proposed change: fix the null check and the issues above and add unit tests, including empty-string input.

主要言語
Java
スター
1.1k
フォーク
655
平均マージ
4時間 54分
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

spring-cloud/spring-cloud-function のほかの issue

spring-cloud/spring-cloud-function の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。