[GitHub] [pulsar] eolivelli commented on a change in pull request #10586: Fix NPE when ACK grouping tracker checks duplicated message id

2021-05-14 Thread GitBox


eolivelli commented on a change in pull request #10586:
URL: https://github.com/apache/pulsar/pull/10586#discussion_r632365085



##
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageIdImpl.java
##
@@ -210,7 +210,8 @@ public int compareTo(MessageId o) {
 } else if (o instanceof TopicMessageIdImpl) {
 return compareTo(((TopicMessageIdImpl) o).getInnerMessageId());
 } else {
-throw new UnsupportedOperationException("Unknown MessageId type: " 
+ o.getClass().getName());
+final String typeName = (o != null) ? o.getClass().getName() : 
"null";

Review comment:
   what about adding a check in the beginning of the method ? the code will 
be easier to read. null checks are not expensive
   
   ```
   if (o == null) {
  throw new UnsupportedOperationException()
   }
   ```




-- 
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:
us...@infra.apache.org




[GitHub] [pulsar] eolivelli commented on a change in pull request #10586: Fix NPE when ACK grouping tracker checks duplicated message id

2021-05-14 Thread GitBox


eolivelli commented on a change in pull request #10586:
URL: https://github.com/apache/pulsar/pull/10586#discussion_r632365085



##
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageIdImpl.java
##
@@ -210,7 +210,8 @@ public int compareTo(MessageId o) {
 } else if (o instanceof TopicMessageIdImpl) {
 return compareTo(((TopicMessageIdImpl) o).getInnerMessageId());
 } else {
-throw new UnsupportedOperationException("Unknown MessageId type: " 
+ o.getClass().getName());
+final String typeName = (o != null) ? o.getClass().getName() : 
"null";

Review comment:
   we can add a check in the beginning of the method.
   
   ```
   if (o == null) {
  throw new UnsupportedOperationException()
   }
   ```




-- 
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:
us...@infra.apache.org