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 2020/06/22 08:43:17 UTC

[GitHub] [pulsar] ErikJansenIRefact opened a new issue #7333: SchemaParseException

ErikJansenIRefact opened a new issue #7333:
URL: https://github.com/apache/pulsar/issues/7333


   **Describe the bug**
   Create a producer with a schema from a polo class returns a schema parse exception
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Create a class LineItem:
   public class LineItem {
       public int orderNbr;
       public int partNbr;
       public int supplierNbr;
       public int lineNbr;
       public Double quantity;
       public Double extendedPrice;
       public Double discount;
       public String shipDate;
       public String comment;
   }
   2. Create a new producer with an Avro schema from the LineItem class
   
   Producer<LineItem> producer = client.newProducer(Schema.JSON(LineItem.class))
   .topic(topicName)
   
   3. Expected a new producer but an exception is thrown instead:
   
   Exception in thread โ€œmainโ€ org.apache.pulsar.shade.org.apache.avro.SchemaParseException: Illegal character in: this$0
           at org.apache.pulsar.shade.org.apache.avro.Schema.validateName(Schema.java:1532)
           at org.apache.pulsar.shade.org.apache.avro.Schema.access$400(Schema.java:87)
           at org.apache.pulsar.shade.org.apache.avro.Schema$Field.<init>(Schema.java:520)
           at org.apache.pulsar.shade.org.apache.avro.Schema$Field.<init>(Schema.java:559)
           at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:630)
           at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:335)
           at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:332)
           at java.lang.ClassValue.getFromHashMap(ClassValue.java:227)
           at java.lang.ClassValue.getFromBackup(ClassValue.java:209)
           at java.lang.ClassValue.get(ClassValue.java:115)
           at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:346)
           at org.apache.pulsar.client.impl.schema.StructSchema.extractAvroSchema(StructSchema.java:174)
           at org.apache.pulsar.client.impl.schema.StructSchema.createAvroSchema(StructSchema.java:161)
           at org.apache.pulsar.client.impl.schema.StructSchema.parseSchemaInfo(StructSchema.java:187)
           at org.apache.pulsar.client.impl.schema.JSONSchema.of(JSONSchema.java:96)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           at java.lang.reflect.Method.invoke(Method.java:498)
           at org.apache.pulsar.client.internal.DefaultImplementation.lambda$newJSONSchema$26(DefaultImplementation.java:242)
           at org.apache.pulsar.client.internal.ReflectionUtils.catchExceptions(ReflectionUtils.java:35)
           at org.apache.pulsar.client.internal.DefaultImplementation.newJSONSchema(DefaultImplementation.java:239)
           at org.apache.pulsar.client.api.Schema.JSON(Schema.java:260)
           at CsvExample.createProducer(CsvExample.java:139)
           at CsvExample.sendMessages(CsvExample.java:44)
   
   


----------------------------------------------------------------
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



[GitHub] [pulsar] ErikJansenIRefact edited a comment on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
ErikJansenIRefact edited a comment on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-648741488


   
   
   Hi @vzhikserg,
   
   Thanks for testing. We've tested with JSON and AVRO both resulting in the same error (Schema.JSON and Schema.AVRO).
   Enclosed the example code which results in an error. Perhaps you are able to reproduce with this code sample.
   
   Kind regards,
   
   Erik
   [CsvExample.java.zip](https://github.com/apache/pulsar/files/4824785/CsvExample.java.zip)
   
   


----------------------------------------------------------------
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



[GitHub] [pulsar] vzhikserg commented on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
vzhikserg commented on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-649496906


   There is one more solution - define the inner class as static. In this case it will not contain any reference to the outer class.
   
   Apache Pulsar uses Apache AVRO to work with schemas. If you still think that this particular case is a bug, please [submit the issue](https://issues.apache.org/jira/projects/AVRO/) to the Apache AVRO project instead of this one.
   
   Best regards,
   Sergii


----------------------------------------------------------------
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



[GitHub] [pulsar] ErikJansenIRefact commented on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
ErikJansenIRefact commented on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-649488663


   Hi @vzhikserg,
   
   Thanks for investigating.  Do you think this should be a change request: support schema with inner classes?
   
   Kind regards,
   
   Erik


----------------------------------------------------------------
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



[GitHub] [pulsar] vzhikserg commented on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
vzhikserg commented on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-648395158


   @ErikJansenIRefact I was not able to reproduce this issue. Pulsar clients (2.5.2 and 2.6.0) are able to create the producer and publish messages. The stacktrace suggests that the issue is somewhere else with a producer using JSON schema
   
   ![image](https://user-images.githubusercontent.com/7816474/85456419-3ca38b80-b59f-11ea-890f-1bc7ee639473.png)
   
   Please provide more information or create a dedicated small project on github reproducing the issue.
   


----------------------------------------------------------------
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



[GitHub] [pulsar] ErikJansenIRefact commented on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
ErikJansenIRefact commented on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-649502305


   Hi Sergii,
   
   Thanks a lot for your help. Your 2 proposed solutions will be sufficient.
   
   Kind regards,
   
   Erik


----------------------------------------------------------------
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



[GitHub] [pulsar] jiazhai commented on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
jiazhai commented on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-648529623


   Thanks @ErikJansenIRefact for the reporting. Thanks @vzhikserg for taking care of it.


----------------------------------------------------------------
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



[GitHub] [pulsar] ErikJansenIRefact closed issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
ErikJansenIRefact closed issue #7333:
URL: https://github.com/apache/pulsar/issues/7333


   


----------------------------------------------------------------
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



[GitHub] [pulsar] vzhikserg commented on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
vzhikserg commented on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-649485706


   Thanks for the provided sample!  I was able to reproduce the issue ๐Ÿ˜‰ The problem is that the LineItem class is a part of the other class (CsvExample). The inner class (LineItem) is a member of the enclosing class (CsvExample) and contains some additional info about it. In this case AVRO has troubles to create a schema for the inner class.
   
   Your sample should work if the inner class (LineItem) is moved to its own class/separate file. 


----------------------------------------------------------------
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



[GitHub] [pulsar] ErikJansenIRefact commented on issue #7333: SchemaParseException

Posted by GitBox <gi...@apache.org>.
ErikJansenIRefact commented on issue #7333:
URL: https://github.com/apache/pulsar/issues/7333#issuecomment-648741488


   Hi @vzhikserg,
   
   Thanks for testing. We've tested with JSON and AVRO both resulting in the same error (Schema.JSON and Schema.AVRO).
   Enclosed the example code which results in an error. Perhaps you are able to reproduce with this code sample.
   
   Kind regards,
   
   Erik
   [CsvExample.java.zip](https://github.com/apache/pulsar/files/4824785/CsvExample.java.zip)
   
   


----------------------------------------------------------------
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