Add support for handling special types

There are certain cases where conversion has to be skiped. One such case is KafkaNull type which has to be sent as is.
This commit is contained in:
Oleg Zhurakousky
2020-07-24 14:45:57 +02:00
parent 0a831e39ae
commit cd9f594629

View File

@@ -828,6 +828,9 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
}
}
else if (!FunctionTypeUtils.isMessage(type)) {
if (this.payloadIsSpecialType(((Message<?>) value).getPayload())) {
return null;
}
convertedValue = ((Message<?>) convertedValue).getPayload();
}
}
@@ -877,7 +880,14 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
}
return rawType instanceof Class<?>
&& !(message.getPayload() instanceof Optional)
&& !this.payloadIsSpecialType(message.getPayload())
&& !(message.getPayload().getClass().isAssignableFrom(((Class<?>) rawType)));
}
private boolean payloadIsSpecialType(Object payload) {
return "org.springframework.kafka.support.KafkaNull".equals(payload.getClass().getName());
}
}
}