Repository navigation
Fixers fixes (ported to v5.0.4) #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |
|
|
||
| import java.lang.reflect.ParameterizedType; | ||
| import java.lang.reflect.Type; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.function.Consumer; | ||
| import java.util.function.Function; | ||
| import java.util.function.Supplier; | ||
|
|
@@ -213,28 +215,47 @@ private boolean isValidKotlinFunction(Type functionType, Type[] type) { | |
| !isTypeRepresentedByClass(type[1], Unit.class); | ||
| } | ||
|
|
||
| // KOMUNE Modification | ||
| // Relaxed arity checks so Kotlin suspend lambdas declared without an explicit | ||
| // Continuation/Flow parameter are still detected, and match supertypes as well. | ||
| private boolean isValidKotlinSuspendSupplier(Type functionType, Type[] type) { | ||
| return isTypeRepresentedByClass(functionType, Function1.class) && | ||
| type.length == 2 && | ||
| CoroutinesUtils.isContinuationFlowType(type[0]); | ||
| (type.length == 1 || (type.length == 2 && CoroutinesUtils.isContinuationFlowType(type[0]))); | ||
| } | ||
|
|
||
| private boolean isValidKotlinSuspendConsumer(Type functionType, Type[] type) { | ||
| return isTypeRepresentedByClass(functionType, Function2.class) && | ||
| type.length == 3 && | ||
| CoroutinesUtils.isFlowType(type[0]) && | ||
| CoroutinesUtils.isContinuationUnitType(type[1]); | ||
| ( | ||
| type.length == 1 || | ||
| (type.length == 3 && CoroutinesUtils.isContinuationUnitType(type[1]) && CoroutinesUtils.isFlowType(type[0])) | ||
| ); | ||
| } | ||
|
|
||
| private boolean isValidKotlinSuspendFunction(Type functionType, Type[] type) { | ||
| return isTypeRepresentedByClass(functionType, Function2.class) && | ||
| type.length == 3 && | ||
| CoroutinesUtils.isContinuationFlowType(type[1]); | ||
| ((type.length == 3 && CoroutinesUtils.isContinuationFlowType(type[1])) | ||
| || type.length == 2); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: rg -n -C 8 'findType\s*\(' spring-cloud-function-context/src/main
rg -n -C 5 'Function2|suspend|KotlinFunctionWrapper' \
spring-cloud-function-context/src/testRepository: komune-io/spring-cloud-function Length of output: 18925 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- changed file ---'
sed -n '120,275p' spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/KotlinLambdaToFunctionAutoConfiguration.java
printf '%s\n' '--- findType implementation ---'
sed -n '41,145p' spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/FunctionContextUtils.java
printf '%s\n' '--- relevant diff ---'
git diff --unified=25 f95cb35447b55e3246bccd072309326310a50e0e ddea02af8391e87f9e7383c8ccce7fdb943ef02a -- spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/KotlinLambdaToFunctionAutoConfiguration.java
printf '%s\n' '--- Kotlin declarations and tests ---'
rg -n -S -g '*.kt' -g '*.java' 'Function2|Function1|SuspendFunction|suspend|KotlinLambdaToFunctionAutoConfiguration|KotlinFunctionWrapper' spring-cloud-function-context spring-cloud-function-adapter spring-cloud-function-kotlin 2>/dev/null || trueRepository: komune-io/spring-cloud-function Length of output: 26377 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- type discovery ---'
rg -n -C 12 'discoverFunctionTypeFromClass\s*\(' spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/FunctionTypeUtils.java
printf '%s\n' '--- wrapper dispatch ---'
sed -n '55,125p' spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/KotlinLambdaToFunctionAutoConfiguration.java
printf '%s\n' '--- Kotlin bean declarations ---'
sed -n '1,90p' spring-cloud-function-kotlin/src/test/kotlin/org/springframework/cloud/function/kotlin/KotlinSuspendLambdasConfiguration.kt
sed -n '1,75p' spring-cloud-function-kotlin/src/test/kotlin/org/springframework/cloud/function/kotlin/KotlinSuspendFlowLambdasConfiguration.ktRepository: komune-io/spring-cloud-function Length of output: 9023 🏁 Script executed: #!/bin/bash
set -u
sed -n '175,250p' spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/FunctionTypeUtils.java
sed -n '250,330p' spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/FunctionTypeUtils.java
rg -n -C 8 'discoverFunctionTypeFromType|resolveType\s*\(' spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/FunctionTypeUtils.javaRepository: komune-io/spring-cloud-function Length of output: 11939 Resolve the implemented When a bean factory method returns a parameterized concrete class that directly implements Resolve the implemented function signature before classification. Require the continuation checks for the resolved signature. Apply the same resolution to the new supplier and consumer branches. 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| private boolean isTypeRepresentedByClass(Type type, Class<?> clazz) { | ||
| return type.getTypeName().contains(clazz.getName()); | ||
| return concatWithSuperTypes(type) | ||
| .stream() | ||
| .map(Type::getTypeName) | ||
| .map(s -> s.contains(clazz.getName())) | ||
| .reduce((a, b) -> a || b) | ||
| .orElse(false); | ||
| } | ||
|
|
||
| private List<Type> concatWithSuperTypes(Type type) { | ||
| List<Type> all = new ArrayList<>(); | ||
| all.add(type); | ||
| if (type instanceof ParameterizedType) { | ||
| Class<?>[] interfaces = ((Class<?>) ((ParameterizedType) type).getRawType()).getInterfaces(); | ||
| all.addAll(List.of(interfaces)); | ||
| } | ||
| return all; | ||
| } | ||
| // KOMUNE End Of Modification | ||
|
|
||
| public Class<?> getObjectType() { | ||
| return FunctionRegistration.class; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: komune-io/spring-cloud-function
Length of output: 4541
🏁 Script executed:
Repository: komune-io/spring-cloud-function
Length of output: 41697
🏁 Script executed:
Repository: komune-io/spring-cloud-function
Length of output: 45685
Map typed collection conversion failures to HTTP 400.
JacksonMapper.doFromJsonwraps invalid element deserialization inIllegalStateException. This direct collection conversion occurs beforeJsonMessageConverter, so the failure can bypass itsResponseStatusException(HttpStatus.BAD_REQUEST, ...)mapping and reach the HTTP layer as a 500. Apply the same input-error mapping to this path.🤖 Prompt for AI Agents