Kotlin function wrapper treats empty input as no input
维护者通常 1 天内回复
评估
调研方向
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 分钟
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 个 reaction ·
维护者通常 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 小时 新手友好度 62/100
-
难度 1/5 1 小时以内 新手友好度 80/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
aphtech/brailleblaster#209 ·
维护者通常 1 天内回复
-
payers.csv writes QOLS_AVG as NaN for every payer that had no members可能已有人在做 @DG47 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 86/100
synthetichealth/synthea#1797 ·
维护者通常 19 天内回复
-
build enhancement security
难度 2/5 1-3 小时 新手友好度 78/100
midhunhk/lib-aeapps#54 ·