Kotlin function wrapper treats empty input as no input
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 3/5
- Temps estimé
- Une demi-journée
- Accessibilité débutants
- 30/100
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
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.
- Langage dominant
- Java
- Étoiles
- 1.1k
- Forks
- 655
- Merge moyen
- 4 h 54 min
- PR mergées (30 j)
- 10
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de spring-cloud/spring-cloud-function
-
ClassCastException with spring-cloud-function 4.3.6 when a field of type Set is deserializedOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
spring-cloud/spring-cloud-function#1542 ·
Les mainteneurs répondent en général sous 1 jour
-
GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invokerPeut-être pris @zemiles l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 32/100
spring-cloud/spring-cloud-function#1544 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
spring-cloud/spring-cloud-function#1538 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Default JSON mapper collection limit is hard-coded and replaces all collection deserializationOuverte5.0.x backport bug
Difficulté 4/5 3-5 jours Accessibilité débutants 22/100
spring-cloud/spring-cloud-function#1536 ·
Les mainteneurs répondent en général sous 1 jour
-
SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion pathsPeut-être pris @seonwooj0810 l’a pris il y a 1 jour. Ouverte5.0.x backport bug
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
spring-cloud/spring-cloud-function#1535 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de spring-cloud/spring-cloud-function
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
bug devops low
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
enhancement
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
MDMesh-app/MDMesh#252 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 80/100
Les mainteneurs répondent en général sous 1 jour