-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cleanup][broker][Modernizer] fix violations in pulsar-broker #17691
Conversation
import com.google.common.collect.Range; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Predicate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. As we enable Modernizer for managed-ledger already, doesn't this file cause failure already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/Users/mac/projects/source_code/pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription$3.java:-1: Prefer java.util.function.Predicate
here is the only one guava Predicate
in PersistentSubscription, an anonymous class:
Lines 558 to 563 in e73b298
return cursor.scan(position, new Predicate<Entry>() { | |
@Override | |
public boolean apply(Entry entry) { | |
if (log.isDebugEnabled()) { | |
log.debug("found {}", entry); | |
} |
moderinzer use ASM to scan the class files and detect the latency usage.
current rule only detect implementing legacy interfaces
, see gaul/modernizer-maven-plugin#1
I build a test case and debug it,
found that modernizer use a map to store all rules, and match with the class token by absolutely equal
(not contains
):
private final Map<String, Violation> violations;
...
Violation violation = violations.get(token);
checkToken(token, violation, name, lineNumber);
actually, this case is detected in the interface list,
that is where the lineNumber=-1
from:
for (String itr : interfaces) {
Violation violation = violations.get(itr);
checkToken(itr, violation, name, /*lineNumber=*/ -1);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. One comment out of curiosity.
/pulsarbot run-failure-checks |
Master Issue: #12271 #16991
Motivation
Apply Maven Modernizer plugin to enforce we move away from legacy APIs.
Modifications
Verifying this change
This change is already covered by existing tests, such as (please describe tests).
Does this pull request potentially affect one of the following parts:
Documentation
doc-not-needed
Matching PR in forked repository
PR in forked repository: youzipi#1