Kotlin function wrapper treats empty input as no input
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 30/100
調査の方向性
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 の本文から書いたものです。
説明
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 toParameterizedTypewithout checking it, which fails withNullPointerExceptionorClassCastExceptionif 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 isTypeRepresentedByClassusesgetTypeName().contains("kotlin.jvm.functions.Function1"), which also matchesFunction10toFunction19(andFunction2matchesFunction20toFunction22)
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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-cloud/spring-cloud-function のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
spring-cloud/spring-cloud-function#1542 ·
メンテナーはふだん 1 日以内に返信
-
GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invoker対応中かも @zemiles が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 32/100
spring-cloud/spring-cloud-function#1544 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
spring-cloud/spring-cloud-function#1538 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
5.0.x backport bug
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
spring-cloud/spring-cloud-function#1536 ·
メンテナーはふだん 1 日以内に返信
-
SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion paths対応中かも @seonwooj0810 が 1 日前に担当しました。 オープン5.0.x backport bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
spring-cloud/spring-cloud-function#1535 ·
メンテナーはふだん 1 日以内に返信
spring-cloud/spring-cloud-function の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug devops low
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
enhancement
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
MDMesh-app/MDMesh#252 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信