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/03/18 18:47:24 UTC

[GitHub] [pulsar] jianyun8023 opened a new issue #9964: [BUG] SchemaInfo toString occurs NPE

jianyun8023 opened a new issue #9964:
URL: https://github.com/apache/pulsar/issues/9964


   **Describe the bug**
   
   Writing`schemaInfo#properties` may cause the client not to consume it when it is a Pulsar native type.
   
   **To Reproduce**
   Write `key` to `SchemaInfo#properties` has value, `value` is null, update schema. create subscriber will fail, throw NPE.
   example code :
   ```
   public static void main(String[] args) throws PulsarClientException, PulsarAdminException {
           final String topicName = "persistent://public/default/newtopic123" + RandomStringUtils.randomNumeric(4);
           Schema schema = Schema.INT32;
           final SchemaInfo schemaInfo = schema.getSchemaInfo();
           Map<String, String> map = new HashMap<>();
           map.put("key", null);
           schemaInfo.setProperties(map);
           final PulsarAdmin pulsarAdmin = PulsarAdmin.builder().serviceHttpUrl("http://127.0.0.1:8080").build();
           pulsarAdmin.topics().createPartitionedTopic(topicName, 1);
           pulsarAdmin.schemas().createSchema(topicName, schemaInfo);
           System.out.println(
                   "pulsarAdmin.schemas().getSchemaInfo(topicName) = " + pulsarAdmin.schemas().getSchemaInfo(topicName));
           try (
                   PulsarClient pulsarClient = PulsarClient.builder()
                           .serviceUrl("pulsar://localhost:6650")
                           .build();
   
           ) {
   
               final Consumer consumer = pulsarClient.newConsumer(Schema.INT32).topic(topicName)
                       .subscriptionName("consumer")
                       .subscribe();
           }
       }
   ```
   
   Console output.
   
   ```
   [pulsar-client-io-8-1] INFO org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/newtopic1237402-partition-0][consumer] Subscribing to topic on cnx [id: 0xc571d5ce, L:/127.0.0.1:52629 - R:localhost/127.0.0.1:6650], consumerId 0
   [pulsar-client-io-8-1] WARN org.apache.pulsar.client.impl.ConnectionHandler - [persistent://public/default/newtopic1237402-partition-0] [consumer] Error connecting to broker: java.lang.NullPointerException
   [pulsar-client-io-8-1] WARN org.apache.pulsar.client.impl.ConnectionHandler - [persistent://public/default/newtopic1237402-partition-0] [consumer] Could not get connection to broker: java.lang.NullPointerException -- Will try again in 1.53 s
   [pulsar-timer-11-1] INFO org.apache.pulsar.client.impl.ConnectionHandler - [persistent://public/default/newtopic1237402-partition-0] [consumer] Reconnecting after connection was closed
   [pulsar-client-io-8-1] INFO org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/newtopic1237402-partition-0][consumer] Subscribing to topic on cnx [id: 0xc571d5ce, L:/127.0.0.1:52629 - R:localhost/127.0.0.1:6650], consumerId 0
   [pulsar-client-io-8-1] WARN org.apache.pulsar.client.impl.ConnectionHandler - [persistent://public/default/newtopic1237402-partition-0] [consumer] Error connecting to broker: java.lang.NullPointerException
   [pulsar-client-io-8-1] WARN org.apache.pulsar.client.impl.ConnectionHandler - [persistent://public/default/newtopic1237402-partition-0] [consumer] Could not get connection to broker: java.lang.NullPointerException -- Will try again in 2.93 s
   
   ```
   
   After troubleshooting once, the problem occurs with the `schemaInfo.toString()` implementation. Trying to call the same NPE occurs
   
   
   **Expected behavior**
   Normal creation of consumer consumption messages
   
   **Screenshots**
   If applicable, add screenshots to help explain your problem.
   
   **Desktop (please complete the following information):**
    - OS: [e.g. iOS]
   
   **Additional context**
   Add any other context about the problem here.
   


-- 
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 closed issue #9964: [BUG] SchemaInfo toString occurs NPE

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


   


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