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/09/20 22:27:22 UTC

[GitHub] [pulsar] rdhabalia opened a new pull request #12106: [pulsar-client] Fix NPE in pulsar bolt while publishing messages

rdhabalia opened a new pull request #12106:
URL: https://github.com/apache/pulsar/pull/12106


   ### Motivation
   Fix NPE when pulsar-storm bolt or any other client app tries to create message without initializing producer in it.
   ```
   java.lang.NullPointerException
   	at org.apache.pulsar.client.impl.TypedMessageBuilderImpl.getMessage(TypedMessageBuilderImpl.java:285)
   	:
   	at org.apache.pulsar.storm.TupleToMessageMapper.toMessage(TupleToMessageMapper.java:50)
   	at org.apache.pulsar.storm.PulsarBolt.execute(PulsarBolt.java:126)
   ```
   


-- 
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] merlimat commented on a change in pull request #12106: [pulsar-client] Fix NPE in pulsar bolt while publishing messages

Posted by GitBox <gi...@apache.org>.
merlimat commented on a change in pull request #12106:
URL: https://github.com/apache/pulsar/pull/12106#discussion_r712622946



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/TypedMessageBuilderImpl.java
##########
@@ -284,7 +284,7 @@ public MessageMetadata getMetadataBuilder() {
 
     public Message<T> getMessage() {
         beforeSend();
-        return MessageImpl.create(msgMetadata, content, schema, producer.topic);
+        return MessageImpl.create(msgMetadata, content, schema, producer != null ? producer.getTopic() : null);

Review comment:
       In what case can we get that producer is null? 
   
   the field is defined as: 
   
   ```
       private transient final ProducerBase<?> producer;
   ```
   
   and we create the message builder starting from the producer. Would that mean that the message builder was serialized and passed around?




-- 
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] rdhabalia commented on a change in pull request #12106: [pulsar-client] Fix NPE in pulsar bolt while publishing messages

Posted by GitBox <gi...@apache.org>.
rdhabalia commented on a change in pull request #12106:
URL: https://github.com/apache/pulsar/pull/12106#discussion_r713269754



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/TypedMessageBuilderImpl.java
##########
@@ -284,7 +284,7 @@ public MessageMetadata getMetadataBuilder() {
 
     public Message<T> getMessage() {
         beforeSend();
-        return MessageImpl.create(msgMetadata, content, schema, producer.topic);
+        return MessageImpl.create(msgMetadata, content, schema, producer != null ? producer.getTopic() : null);

Review comment:
       It happens when some legacy applications want to create a message using internal `TypedMessageBuilderImpl` API without initializing producer. eg: `pulsarMessageBuilder = new TypedMessageBuilderImpl(null, Schema.BYTES);`. we have few legacy API including wrapper on pulsar-storm which uses it to maintain backward compatibility as pulsar-v2 API has changed from v1 and we are not maintaining v1 API with all changes. so, it handles NPE when application tries to create message without initializing producer. 
   




-- 
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] merlimat merged pull request #12106: [pulsar-client] Fix NPE in pulsar bolt while publishing messages

Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #12106:
URL: https://github.com/apache/pulsar/pull/12106


   


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