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/04/11 04:25:19 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #4022: Making use of builtin schemas for primitive types

sijie commented on a change in pull request #4022: Making use of builtin schemas for primitive types
URL: https://github.com/apache/pulsar/pull/4022#discussion_r274244695
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/BooleanSchema.java
 ##########
 @@ -31,17 +33,18 @@
     public static BooleanSchema of() {
         return INSTANCE;
     }
+    private static final org.apache.avro.Schema schema = org.apache.avro.Schema.create(org.apache.avro.Schema.Type.BOOLEAN);
 
     private static final BooleanSchema INSTANCE = new BooleanSchema();
-    private static final SchemaInfo SCHEMA_INFO = new SchemaInfo()
+    public static final SchemaInfo SCHEMA_INFO = new SchemaInfo()
             .setName("Boolean")
             .setType(SchemaType.BOOLEAN)
-            .setSchema(new byte[0]);
+            .setSchema(schema.toString().getBytes(UTF_8));
 
     @Override
     public void validate(byte[] message) {
-        if (message.length != 1) {
-            throw new SchemaSerializationException("Size of data received by BooleanSchema is not 1");
+        if (message.length < 1) {
 
 Review comment:
   @srkukarni I am not sure what is the purpose of changing `!=` to `<`. IMO this is incorrect, we should do exact size checking, since both `encode` and `decode` is expecting the byte array to have correct length.

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