findbugs complains incorrectly that a private static method is not used. However this method is actually called using the new method reference syntax of Java 8. The workaround here is simple: replace the method reference with an actual method call. Example:
public List<String> readLocations(final List<String> inputs) {
return inputs.stream()
.map(MyClass::createPath)
// here comes more code..;
}
private static Path createPath(final String input) {
// doesn't matter
return null;
}
The workaround replaces
.map(MyClass::createPath)
with
.map(input -> createPath(input))
Testcase is committed:
https://code.google.com/p/findbugs/source/detail?r=5c9848da8e5ae79892545dd3689d7bc071413a3f
I cannot reproduce your problem in FB 3.0.1. Of course it persists in 3.0.0, but we've fixed it. Which version of FindBugs are you using?
Related
Bugs:
#1295You are right! I was using version 3.0.0 of the findbugs-maven-plugin. Switching to version 3.0.1 which was just released, fixes this problem. Thanks a lot!
In case of overloaded methods still findbugs reports same error. Its working only after I change the method name.
For below scenario, findbug reports UPM_UNCALLED_PRIVATE_METHOD.
I'm able to unblock my self changing createPath(final String input) method name.
Last edit: SRINIVAS MACHERLA 2018-08-16
Reopened bug here https://github.com/spotbugs/spotbugs/issues/735