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 2021/02/24 12:34:49 UTC

[GitHub] [pulsar] epsteina16 opened a new issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

epsteina16 opened a new issue #9697:
URL: https://github.com/apache/pulsar/issues/9697


   **Describe the bug**
   Calling GenericRecord.getField(Field field) on a GenericRecord that is a sub-record, where the field is a string, the Pulsar client throws a NullPointerException:
   
   java.lang.NullPointerException
   	at org.apache.pulsar.client.impl.schema.generic.GenericJsonRecord.isBinaryValue(GenericJsonRecord.java:110)
   	at org.apache.pulsar.client.impl.schema.generic.GenericJsonRecord.getField(GenericJsonRecord.java:87)
   	at org.apache.pulsar.client.api.schema.GenericRecord.getField(GenericRecord.java:53)
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Using the Pulsar Java Client create a consumer of type Schema.AUTO_CONSUME, to receive GenericRecords from the broker.
   2. Fill the topic with messages with a subrecord with a string in it, in the form of a JsonSchema. This is an example schema:
       {
   	"type": "JSON",
           "schema": "{\"type\":\"record\",\"namespace\":\"com.example\",\"name\":\"MyJsonSchema\",\"fields\":[{\"name\":\"subrecord_field\",\"type\":{\"type\":\"record\",\"name\":\"subrecord_field\",\"fields\":[{\"name\":\"substring_field\",\"type\":\"string\"}]}}]}",
   	"properties": {}
   }  
   3. When a message is received, get the subrecord by calling .getField(Field field) on the top level record.
   4. The try to get the field for the substring field by calling .getField() on the subrecord.
   
   Example code:
   GenericRecord subRecord = record.getField("subrecord_field");
   subRecord.getField("substring_field"); // This will throw a null pointer exception
   
   **Expected behavior**
   getField should return the Object that is the field. i.e. for this, we should get a String back.
   
   **Desktop (please complete the following information):**
    - OS: linux
   
   **Additional context**
   Pulsar client version 2.7.0
   
   


----------------------------------------------------------------
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] eolivelli commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   I believe that probably this has already been fixed


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] congbobo184 edited a comment on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   @epsteina16 does the ```subrecord_field``` have value?  I test the scenes, if it have value then it will not throw NPE. it don't have value it will throw NPE.


----------------------------------------------------------------
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] codelipenghui commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   @epsteina16 Agree, I notice `substring_field` is not allow null from the schema definition right? Can the writer write a message with `substring_field=null`?
   
   @congbobo184 I think we need to fix this case, we should check if the GenericRecord has this field, if not, we should return null. You mentioned have value or don't have value, this means not null or null? 


----------------------------------------------------------------
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] epsteina16 commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   The `subrecord_field` contains fields. Whether or not `substring_field` is an empty string or has content, I see this. Pulsar should not have a NPE either way.


----------------------------------------------------------------
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] michaeljmarshall commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   @epsteina16 - can you confirm whether or not this bug is still present in recent releases of Pulsar? We are releasing 2.7.4 now, so I am going to remove this label. However, if the bug still exists, we should fix it. Thanks


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] codelipenghui commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   The issue had no activity for 30 days, mark with Stale label.


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] congbobo184 commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   @epsteina16 does the ```subrecord_field``` have value? 


----------------------------------------------------------------
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] congbobo184 commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   Move this to the next release.


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] codelipenghui commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   @congbobo184 Could you please take a look at this 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] eolivelli commented on issue #9697: Java Client: NullPointerException with GenericRecord.getField() on a sub-record

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


   @vroyer PTAL
   are you interested in providing a fix ? 


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