In the ConnectorResultHandler.createOutputVariables method, the program checks whether the resultExpression is empty. If it is not empty, it performs mapping for the value of responseContent. However, if responseContent == null, the mapping logic will throw an error: “Failed to evaluate expression ‘=xxxxxxx’ in context, Reason: Context is null.”
It is recommended to check whether the response is null before calling the createOutputVariables method. If it is null, the result set mapping should be skipped, and the method should return directly:
private ConnectorResult getConnectorResult(ActivatedJob job) {
Duration retryBackoff = null;
try {
retryBackoff = getBackoffDuration(job);
var context =
new JobHandlerContext(
job, getSecretProvider(), validationProvider, documentFactory, objectMapper);
var response = call.execute(context);
if (response == null) {
return new ConnectorResult.SuccessResult(null, null);
}
var responseVariables =
connectorResultHandler.createOutputVariables(
response,
job.getCustomHeaders().get(Keywords.RESULT_VARIABLE_KEYWORD),
job.getCustomHeaders().get(Keywords.RESULT_EXPRESSION_KEYWORD));
return new ConnectorResult.SuccessResult(response, responseVariables);
} catch (Exception e) {
return outboundConnectorExceptionHandler.manageConnectorJobHandlerException(
e, job, retryBackoff);
}
}