Kotlin function wrapper treats empty input as no input
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 30/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Java
- Estrellas
- 1.1k
- Forks
- 655
- Merge medio
- 4 h 54 min
- PR fusionados (30 d)
- 10
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de spring-cloud/spring-cloud-function
-
ClassCastException with spring-cloud-function 4.3.6 when a field of type Set is deserializedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
spring-cloud/spring-cloud-function#1542 ·
Los mantenedores suelen responder en 1 día
-
GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invokerPosiblemente ocupada @zemiles la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 32/100
spring-cloud/spring-cloud-function#1544 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
spring-cloud/spring-cloud-function#1538 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Default JSON mapper collection limit is hard-coded and replaces all collection deserializationAbierto5.0.x backport bug
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
spring-cloud/spring-cloud-function#1536 ·
Los mantenedores suelen responder en 1 día
-
SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion pathsPosiblemente ocupada @seonwooj0810 la tomó hace 1 día. Abierto5.0.x backport bug
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
spring-cloud/spring-cloud-function#1535 ·
Los mantenedores suelen responder en 1 día
Todos los issues de spring-cloud/spring-cloud-function
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug devops low
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
enhancement
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
MDMesh-app/MDMesh#252 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
Los mantenedores suelen responder en 1 día