diff --git a/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/taskdefutil/LHTaskSignature.java b/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/taskdefutil/LHTaskSignature.java index 7a71af93c..7fbe9e067 100644 --- a/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/taskdefutil/LHTaskSignature.java +++ b/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/taskdefutil/LHTaskSignature.java @@ -60,24 +60,17 @@ public LHTaskSignature(String taskDefName, Object executable, String lhTaskMetho + " on " + executable.getClass()); } - VariableType returnType = LHLibUtil.javaClassToLHVarType(taskMethod.getReturnType()); - boolean maskedValue = false; - String outputSchemaVarName = "output"; - if (taskMethod.isAnnotationPresent(LHType.class)) { - LHType type = taskMethod.getAnnotation(LHType.class); - maskedValue = type.masked(); - if (!type.name().isEmpty() || !type.name().isBlank()) { - outputSchemaVarName = type.name(); - } + + Class returnType = taskMethod.getReturnType(); + + buildInputVarsSignature(); + + if (!void.class.isAssignableFrom(returnType)) { + buildOutputSchemaSignature(returnType); } - outputSchema = TaskDefOutputSchema.newBuilder() - .setValueDef(VariableDef.newBuilder() - .setType(returnType) - .setName(outputSchemaVarName) - .setMaskedValue(maskedValue) - .build()) - .build(); + } + private void buildInputVarsSignature() { for (int i = 0; i < taskMethod.getParameterCount(); i++) { Parameter param = taskMethod.getParameters()[i]; if (param.getType().equals(WorkerContext.class)) { @@ -105,6 +98,26 @@ public LHTaskSignature(String taskDefName, Object executable, String lhTaskMetho } } + private void buildOutputSchemaSignature(Class classReturnType) { + VariableType returnType = LHLibUtil.javaClassToLHVarType(classReturnType); + boolean maskedValue = false; + String outputSchemaVarName = "output"; + if (taskMethod.isAnnotationPresent(LHType.class)) { + LHType type = taskMethod.getAnnotation(LHType.class); + maskedValue = type.masked(); + if (!type.name().isEmpty() || !type.name().isBlank()) { + outputSchemaVarName = type.name(); + } + } + outputSchema = TaskDefOutputSchema.newBuilder() + .setValueDef(VariableDef.newBuilder() + .setType(returnType) + .setName(outputSchemaVarName) + .setMaskedValue(maskedValue) + .build()) + .build(); + } + private String varNameFromParameterName(Parameter param) { if (!param.isNamePresent()) { log.warn(