chia7712 commented on PR #16499:
URL: https://github.com/apache/kafka/pull/16499#issuecomment-2217472916
hi @FrankYang0529 the following comments are all about (personally) code
style. They are not Bible, but maybe they can be the start of "making those
code more clear"
1. If the impl is not complicated, we can consider inlining the impl. for
example:
```java
static DetectThreadLeak of(Predicate<Thread> predicate) {
Set<Long> before = Thread.getAllStackTraces().keySet()
.stream().filter(predicate).map(Thread::getId).collect(Collectors.toSet());
return () -> Thread.getAllStackTraces().keySet()
.stream().filter(predicate)
.filter(t -> !before.contains(t.getId()))
.collect(Collectors.toList());
}
```
2. we can leverage the filter to avoid saving the reference of threads. That
will be good to GC.
3. we should use standard Java comments for a method. for instance:
```java
/**
* @return the new threads after `DetectThreadLeak` is created
*/
```
--
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]