see-quick commented on code in PR #20660:
URL: https://github.com/apache/kafka/pull/20660#discussion_r2428409396


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogCleaner.java:
##########
@@ -484,7 +483,9 @@ public CleanerThread(int threadId) throws 
NoSuchAlgorithmException {
                     config.dedupeBufferLoadFactor,
                     throttler,
                     time,
-                    this::checkDone
+                    // Use a lambda instead of method reference to avoid 
`this` escape
+                    // The lambda captures `this` but doesn't evaluate it 
until runtime
+                    topicPartition -> checkDone(topicPartition)

Review Comment:
   Oh yeah...I was verifying that solution on JDK 17 ofc that passes, because 
that `this-escape` is introduced from JDK 21 I hope...The last chance, it came 
to my mind is to make `CleanerThread` final => that would tell compiler that 
class cannnot have sub-classes => and that way it should eliminate 
`this-escape` => because there is no risk of a subclass seeing an in-completely 
initialized object. So basically we can let method reference but just mark 
class `final`.
   



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

Reply via email to