Kotlin function wrapper treats empty input as no input
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- Ein halber Tag
- Anfängerfreundlichkeit
- 30/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Java
- Sterne
- 1.1k
- Forks
- 655
- Ø Merge
- 4 Std. 54 Min.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus spring-cloud/spring-cloud-function
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
spring-cloud/spring-cloud-function#1542 ·
Maintainer antworten meist innerhalb von 1 Tag
-
GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invokerEvtl. vergeben @zemiles hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 32/100
spring-cloud/spring-cloud-function#1544 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
spring-cloud/spring-cloud-function#1538 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Default JSON mapper collection limit is hard-coded and replaces all collection deserializationOffen5.0.x backport bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 22/100
spring-cloud/spring-cloud-function#1536 ·
Maintainer antworten meist innerhalb von 1 Tag
-
SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion pathsEvtl. vergeben @seonwooj0810 hat das vor 1 Tag übernommen. Offen5.0.x backport bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
spring-cloud/spring-cloud-function#1535 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in spring-cloud/spring-cloud-function
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
bug devops low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
enhancement
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
MDMesh-app/MDMesh#252 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 80/100
Maintainer antworten meist innerhalb von 1 Tag