forked from spotbugs/spotbugs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close spotbugs#259: ensure that reported problem is already fixed in …
…SpotBugs
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/nullness/Issue259Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
} | ||
} | ||
} |