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 2022/03/04 11:30:21 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #14556: Make copies of thread local MessageMetadata when it might be shared

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



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/plugin/FilterContext.java
##########
@@ -25,12 +25,23 @@
 @Data
 public class FilterContext {
     private Subscription subscription;
-    private MessageMetadata msgMetadata;
+    private final MessageMetadata msgMetadata = new MessageMetadata();
+
+    public FilterContext() {
+    }
 
     public void reset() {
         subscription = null;
-        msgMetadata = null;
+        msgMetadata.clear();
     }
 
     public static final FilterContext FILTER_CONTEXT_DISABLED = new FilterContext();
+
+    public MessageMetadata getMsgMetadata() {

Review comment:
       This may be problematic because the filter may want to hold a reference to this object (I don't know why  but you know users sometimes do silly things)

##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessagePayloadContextImpl.java
##########
@@ -68,7 +68,7 @@ public static MessagePayloadContextImpl get(final BrokerEntryMetadata brokerEntr
         final MessagePayloadContextImpl context = RECYCLER.get();
         context.consumerEpoch = consumerEpoch;
         context.brokerEntryMetadata = brokerEntryMetadata;
-        context.messageMetadata = messageMetadata;
+        context.messageMetadata.copyFrom(messageMetadata);

Review comment:
       This may be problematic because the filter may want to hold a reference to this object (I don't know why but you know users sometimes do silly things)




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