BewareMyPower commented on a change in pull request #12403:
URL: https://github.com/apache/pulsar/pull/12403#discussion_r775912573
##########
File path:
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
##########
@@ -1293,6 +1349,10 @@ void recycle() {
retryCount = 0;
batchSizeByte = 0;
numMessagesInBatch = 1;
+ if (chunkedMessageCtx != null) {
+ ReferenceCountUtil.safeRelease(chunkedMessageCtx);
+ }
Review comment:
```suggestion
ReferenceCountUtil.safeRelease(chunkedMessageCtx);
```
`safeRelease` can handle null value well. It calls `release` internally:
```java
public static boolean release(Object msg) {
// if `msg` is null, `msg instanceof ReferenceCounted` returns false
return msg instanceof ReferenceCounted ?
((ReferenceCounted)msg).release() : false;
}
```
So we usually use`safeRelease` just to simplify our code to avoid null
checks and swallowing(printing) warnings for invalid reference count.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]