You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/11/05 11:39:15 UTC

[GitHub] [pulsar] wolfstudy opened a new issue #5566: [Java Functions] Use protobuf schema error

wolfstudy opened a new issue #5566: [Java Functions] Use protobuf schema error
URL: https://github.com/apache/pulsar/issues/5566
 
 
   **Describe the bug**
   
   I am trying to write a Java function using the `protobuf` schema, code as follows:
   
   ```
   package functions;
   
   import pb.TestOuterClass;
   
   import java.util.function.Function;
   
   public class ExampleProtoSchemaFunction implements Function<pb.TestOuterClass.Test, String> {
   
       @Override
       public String apply(TestOuterClass.Test test) {
           System.out.println(test.getMsf());
           System.out.println(test.getNum());
           return "test proto schema of function";
       }
   }
   ```
   
   proto definition as follows:
   
   ```
   syntax = "proto3";
   package pb;
   
   message Test {
       int32 num = 1;
       string msf = 2;
   }
   ```
   
   Create a function with the following command:
   
   ```
   ./bin/pulsar-admin functions localrun --name protobbuf-schema-function --tenant public --namespace default --inputs input-topic-1  --jar mysql-sink-io-tests-1.0-SNAPSHOT.jar --output output-topic --classname functions.ExampleProtoSchemaFunction
   ```
   
   I have encountered the following error:
   
   ```
   17:51:00.300 [main] INFO  org.apache.pulsar.functions.LocalRunner - RuntimeSpawner quit because of
   java.lang.UnsupportedOperationException: null
   	at java.util.AbstractMap.put(AbstractMap.java:209) ~[?:1.8.0_201]
   	at org.apache.pulsar.client.impl.schema.SchemaDefinitionBuilderImpl.build(SchemaDefinitionBuilderImpl.java:101) ~[pulsar-client-original.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.client.impl.schema.ProtobufSchema.ofGenericClass(ProtobufSchema.java:107) ~[pulsar-client-original.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.source.TopicSchema.newSchemaInstance(TopicSchema.java:154) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.source.TopicSchema.newSchemaInstance(TopicSchema.java:178) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.source.TopicSchema.newSchemaInstance(TopicSchema.java:210) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.source.TopicSchema.lambda$getSchema$0(TopicSchema.java:66) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at java.util.HashMap.computeIfAbsent(HashMap.java:1127) ~[?:1.8.0_201]
   	at org.apache.pulsar.functions.source.TopicSchema.getSchema(TopicSchema.java:66) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.source.PulsarSource.lambda$setupConsumerConfigs$5(PulsarSource.java:165) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at java.util.TreeMap.forEach(TreeMap.java:1005) ~[?:1.8.0_201]
   	at org.apache.pulsar.functions.source.PulsarSource.setupConsumerConfigs(PulsarSource.java:160) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.source.PulsarSource.open(PulsarSource.java:66) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.instance.JavaInstanceRunnable.setupInput(JavaInstanceRunnable.java:733) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.instance.JavaInstanceRunnable.setupJavaInstance(JavaInstanceRunnable.java:215) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at org.apache.pulsar.functions.instance.JavaInstanceRunnable.run(JavaInstanceRunnable.java:244) ~[pulsar-functions-instance.jar:2.5.0-SNAPSHOT]
   	at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_201]
   17:51:29.813 [function-timer-thread-5-1] ERROR org.apache.pulsar.functions.runtime.RuntimeSpawner - public/default/protobbuf-schema-function-java.lang.UnsupportedOperationException Function Container is dead with exception.. restarting
   ```
   
   **To Reproduce**
   
   Build java function using the code example provided above.
   
   **Expected behavior**
   
   Java function was successfully created
   
   **Screenshots**
   
   ![image](https://user-images.githubusercontent.com/20965307/68204676-81c08080-0003-11ea-875c-008800ffa26a.png)
   
   
   **Desktop (please complete the following information):**
    - OS: Mac OS
    - Pulsar: 2.4.1
   
   **Additional context**
   
   Through the error message, we can locate [SchemaDefinitionBuilderImpl#101](https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/SchemaDefinitionBuilderImpl.java#L101)
   
   When I delete this line of code, this function is created successfully.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services