提问人:boot-and-bonnet 提问时间:4/14/2020 更新时间:4/14/2020 访问量:208
如何在 Eclipse 中防止流畅的资源泄漏警告?
How to prevent fluent resource leak warnings in Eclipse?
问:
有没有办法避免对类型上的流畅样式方法链接出现“潜在资源泄漏”警告?下面的示例在每次方法调用时都有一个警告。AutoCloseable
我宁愿不使用 ,因为无论在使用该类的任何地方都需要它。而且我不想关闭警告,因为我过去发现过许多真正的错误。@SuppressWarnings
随着最新的2020-03日食,误报的数量似乎大大增加,以至于警告几乎无法使用。
public class NoLeak implements AutoCloseable {
public NoLeak a() {
return this;
}
public NoLeak b() {
return this;
}
@Override
public void close() {}
public static void main(String[] args) {
try (NoLeak noLeak = new NoLeak()) {
noLeak
.a() // warning here,
.b() // here,
.a(); // and here
}
}
}
Eclipse 2020-03 (4.15.0),Java 12
答: 暂无答案
评论
java.nio.file.Path.getFileSystem()