Kotlin function wrapper treats empty input as no input

Ouverte
#1,537 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@seonwooj0810 y travaille déjà.

Depuis le 24/11/2026.

  • #1549 par @seonwooj0810 — ouverte

Évaluation

Difficulté
3/5
Temps estimé
Une demi-journée
Accessibilité débutants
30/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
java, kotlin, spring
Domaine
backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Java
Étoiles
1.1k
Forks
655
Merge moyen
4 h 54 min
PR mergées (30 j)
10

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de spring-cloud/spring-cloud-function

Toutes les issues de spring-cloud/spring-cloud-function

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.