Skip to content

Commit

Permalink
Also check cancel calls on ClosingFuture.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 448301248
  • Loading branch information
cpovirk authored and Error Prone Team committed May 12, 2022
1 parent b603cff commit 9dee02f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public class Interruption extends BugChecker implements MethodInvocationTreeMatc

private static final Matcher<ExpressionTree> CANCEL =
instanceMethod()
.onDescendantOf("java.util.concurrent.Future")
.onDescendantOfAny(
"java.util.concurrent.Future", "com.google.common.util.concurrent.ClosingFuture")
.named("cancel")
.withParameters("boolean");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ public void positive() {
.doTest();
}

@Test
public void positiveClosingFuture() {
compilationHelper
.addSourceLines(
"Test.java",
"import com.google.common.util.concurrent.ClosingFuture;",
"class Test {",
" void f(ClosingFuture<?> f) {",
" // BUG: Diagnostic contains: f.cancel(false)",
" f.cancel(true);",
" }",
"}")
.doTest();
}

@Test
public void positiveInterrupt() {
compilationHelper
Expand Down

0 comments on commit 9dee02f

Please sign in to comment.