Kotlin function wrapper treats empty input as no input

Abierto
#1,537 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@seonwooj0810 ya está trabajando en esto.

Desde el 24/11/2026.

  • #1549 de @seonwooj0810 — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
java, kotlin, spring
Área
backend

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

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.

Lenguaje dominante
Java
Estrellas
1.1k
Forks
655
Merge medio
4 h 54 min
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de spring-cloud/spring-cloud-function

Todos los issues de spring-cloud/spring-cloud-function

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.