Skip to content

Commit a1870d1

Browse files
committed
Fix. Input type
1 parent a318e4b commit a1870d1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/java/io/eigr/spawn/internal/Entity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.eigr.spawn.internal;
22

33
import io.eigr.functions.protocol.actors.ActorOuterClass;
4+
import io.eigr.spawn.api.Value;
5+
import io.eigr.spawn.api.actors.ActorContext;
46
import io.eigr.spawn.api.annotations.*;
57
import org.slf4j.Logger;
68
import org.slf4j.LoggerFactory;
@@ -158,6 +160,15 @@ public Method getMethod() {
158160
}
159161

160162
public Class getInputType() {
163+
int arity = method.getParameterTypes().length;
164+
165+
if (arity == 2 && Objects.isNull(inputType)) {
166+
for (Class<?> parameterType : method.getParameterTypes()) {
167+
if (!inputType.isAssignableFrom(ActorContext.class)) {
168+
return parameterType;
169+
}
170+
}
171+
}
161172
return inputType;
162173
}
163174

src/main/java/io/eigr/spawn/internal/handlers/ActorServiceHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ private Optional<Value> callAction(String system, String actor, String commandNa
135135

136136
final Method actorMethod = entityMethod.getMethod();
137137
Class inputType = entityMethod.getInputType();
138+
log.debug("Action input type is: {}", inputType);
138139

139140
ActorContext actorContext;
140141
if (context.hasState()) {
@@ -147,7 +148,7 @@ private Optional<Value> callAction(String system, String actor, String commandNa
147148
if (inputType.isAssignableFrom(ActorContext.class)) {
148149
return Optional.of((Value) actorMethod.invoke(actorRef, actorContext));
149150
} else {
150-
final Object unpack = value.unpack(entityMethod.getInputType());
151+
final Object unpack = value.unpack(inputType);
151152
return Optional.of((Value) actorMethod.invoke(actorRef, unpack, actorContext));
152153
}
153154
} catch (IllegalAccessException e) {

0 commit comments

Comments
 (0)