Reputation: 717
Let's assume the value is a String OR a class object.
context.forward(key, value, topic);
Immediately after the above line, can we do the following? If the records are in producer buffer, will they all get published to topic as null?
value = null;
Upvotes: 0
Views: 74
Reputation: 62330
It's fine, as you pass on references. If value
would be primitive type (not possible of this API), the value would be copied what would also be fine.
What might result in problems is, if you modify the passed object (not possible to do with String
type though). Assume, it's a POJO type, and you call a set()
after context.forward
-- because the downstream node might still use the passed in reference, calling set()
would modify the previous forwarded POJO. This could cause problems.
Upvotes: 1