Describe the bug
I have use cases that get invoked as a result of configuring an SQS event source for a Lambda.
Those use cases do not have return values. They effect the system in other ways, by pushing
messages onto other queues, for example. That is, they have side-effects, just not side-effects
that need to be communicated back to the caller through the return value of the invocation method.
The problem is, when I do not specify a return value, I get a cryptic error message. I expect no error.
To Reproduce
fun main() {
val useCaseMaid = UseCaseMaid.aUseCaseMaid().invoking(MyUseCase::class.java).build()
val result = useCaseMaid.invoke(MyUseCase::class.java, mapOf("hello" to "world"))
}
class MyUseCase {
fun invoke(request: MyRequest) {}
}
data class MyRequest(val s1: String, val s2: String)
I get
java.lang.ClassCastException: class de.quantummaid.mapmaid.mapper.universal.UniversalNull cannot be cast to class de.quantummaid.mapmaid.mapper.universal.UniversalObject (de.quantummaid.mapmaid.mapper.universal.UniversalNull and de.quantummaid.mapmaid.mapper.universal.UniversalObject are in unnamed module of loader 'app')
at de.quantummaid.mapmaid.polymorphy.PolymorphicDeserializer.deserialize(PolymorphicDeserializer.java:70)
at de.quantummaid.mapmaid.mapper.deserialization.InternalDeserializer.deserializeRecursive(InternalDeserializer.java:108)
at de.quantummaid.mapmaid.mapper.deserialization.InternalDeserializer.deserialize(InternalDeserializer.java:71)
at de.quantummaid.mapmaid.mapper.deserialization.Deserializer.deserialize(Deserializer.java:121)
at de.quantummaid.mapmaid.mapper.deserialization.Deserializer.deserializeFromUniversalObject(Deserializer.java:88)
at de.quantummaid.usecasemaid.serializing.SerializerAndDeserializer.lambda$deserializeParameters$0(SerializerAndDeserializer.java:58)
at java.base/java.util.HashMap.forEach(HashMap.java:1336)
at de.quantummaid.usecasemaid.serializing.SerializerAndDeserializer.deserializeParameters(SerializerAndDeserializer.java:54)
at de.quantummaid.usecasemaid.UseCaseMaid.lambda$invoke$2(UseCaseMaid.java:99)
at de.quantummaid.usecasemaid.driver.ExecutionDriver.executeUseCase(ExecutionDriver.java:38)
at de.quantummaid.usecasemaid.UseCaseMaid.invoke(UseCaseMaid.java:94)
at de.quantummaid.usecasemaid.UseCaseMaid.invoke(UseCaseMaid.java:87)
at de.quantummaid.usecasemaid.UseCaseMaid.invoke(UseCaseMaid.java:74)
at de.builderrahmen.controlplane.test.LocalControlPlaneTests.canHandleInvalidControlPlaneProtocolMessage(LocalControlPlaneTests.kt:64)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
Expected behavior
UseCaseResult without error (it has a hasReturnValue() and returnValue() anyway, maybe switch to a single returnValue() returning an Optional<>?
Environment description
- project version used: 0.0.10
- Java version used: n/a
Describe the bug
I have use cases that get invoked as a result of configuring an SQS event source for a Lambda.
Those use cases do not have return values. They effect the system in other ways, by pushing
messages onto other queues, for example. That is, they have side-effects, just not side-effects
that need to be communicated back to the caller through the return value of the invocation method.
The problem is, when I do not specify a return value, I get a cryptic error message. I expect no error.
To Reproduce
I get
Expected behavior
UseCaseResult without error (it has a hasReturnValue() and returnValue() anyway, maybe switch to a single returnValue() returning an Optional<>?
Environment description