Skip to content

Commit

Permalink
close spotbugs#259: ensure that reported problem is already fixed in …
Browse files Browse the repository at this point in the history
…SpotBugs
  • Loading branch information
KengoTODA committed Jul 24, 2017
1 parent 23323b2 commit a5ce836
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.umd.cs.findbugs.nullness;

import edu.umd.cs.findbugs.BugCollection;
import edu.umd.cs.findbugs.test.SpotBugsRule;
import org.junit.Rule;
import org.junit.Test;

import java.nio.file.Paths;

import static org.hamcrest.Matchers.emptyIterable;
import static org.junit.Assert.assertThat;

/**
* Unit test to reproduce <a href="https://github.com/spotbugs/spotbugs/issues/259">#259</a>.
*/
public class Issue259Test {
@Rule
public SpotBugsRule spotbugs = new SpotBugsRule();

@Test
public void test() {
BugCollection bugCollection = spotbugs.performAnalysis(
Paths.get("../spotbugsTestCases/build/classes/java/main/ghIssues/Issue259.class"));
assertThat(bugCollection, emptyIterable());
}
}
15 changes: 15 additions & 0 deletions spotbugsTestCases/src/java/ghIssues/Issue259.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ghIssues;

public class Issue259 {
public void falsePositive() {
try (X x = new X(); X y = new X()) {
throw new IllegalStateException();
} // Redundant nullcheck of x, which is known to be non-null in test.Bug1169.falsePositive()
}

private static class X implements AutoCloseable {
@Override
public void close() {
}
}
}

0 comments on commit a5ce836

Please sign in to comment.