Fix Trigger functionality for non Java Functions
@@ -480,10 +480,6 @@ public class FunctionsImpl {
FunctionMetaData functionMetaData = functionMetaDataManager.getFunctionMetaData(tenant, namespace, functionName);
String inputTopicToWrite;
- // only if the source is PulsarSource and if the function consumes only one topic
- if (!functionMetaData.getFunctionDetails().getSource().getClassName().equals(PulsarSource.class.getName())) {
- return Response.status(Status.BAD_REQUEST).build();
- }
if (topic != null) {
inputTopicToWrite = topic;
} else if (functionMetaData.getFunctionDetails().getSource().getTopicsToSerDeClassNameMap().size() == 1) {
@@ -492,6 +488,10 @@ public class FunctionsImpl {
} else {
return Response.status(Status.BAD_REQUEST).build();
}
+ if (functionMetaData.getFunctionDetails().getSource().getTopicsToSerDeClassNameMap() == null
+ || !functionMetaData.getFunctionDetails().getSource().getTopicsToSerDeClassNameMap().containsKey(inputTopicToWrite)) {
+ return Response.status(Status.BAD_REQUEST).build();
+ }
String outputTopic = functionMetaData.getFunctionDetails().getSink().getTopic();
Reader reader = null;
Producer producer = null;
