Kotlin function wrapper treats empty input as no input
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 30/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 1.1k
- Fork
- 655
- Merge medio
- 4h 54m
- PR unite (30g)
- 10
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di spring-cloud/spring-cloud-function
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
spring-cloud/spring-cloud-function#1542 ·
I maintainer di solito rispondono entro 1 giorno
-
GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invokerForse già presa @zemiles l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 32/100
spring-cloud/spring-cloud-function#1544 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
spring-cloud/spring-cloud-function#1538 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Default JSON mapper collection limit is hard-coded and replaces all collection deserializationAperta5.0.x backport bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
spring-cloud/spring-cloud-function#1536 ·
I maintainer di solito rispondono entro 1 giorno
-
SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion pathsForse già presa @seonwooj0810 l’ha presa 1 giorno fa. Aperta5.0.x backport bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
spring-cloud/spring-cloud-function#1535 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di spring-cloud/spring-cloud-function
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug devops low
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
enhancement
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
MDMesh-app/MDMesh#252 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno