From c5cc053ab7fd9c92f9d4a2b5f0794cb8cc257d8a Mon Sep 17 00:00:00 2001 From: Kengo TODA Date: Tue, 6 Dec 2016 13:28:47 +0800 Subject: [PATCH] refs #60: reproduce reported problem --- .../detect/FindUnsatisfiedObligationTest.java | 22 +++++++++++++++++++ findbugsTestCases/src/java/Issue60.java | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 findbugs/src/test/java/edu/umd/cs/findbugs/detect/FindUnsatisfiedObligationTest.java create mode 100644 findbugsTestCases/src/java/Issue60.java diff --git a/findbugs/src/test/java/edu/umd/cs/findbugs/detect/FindUnsatisfiedObligationTest.java b/findbugs/src/test/java/edu/umd/cs/findbugs/detect/FindUnsatisfiedObligationTest.java new file mode 100644 index 00000000000..a767df98b40 --- /dev/null +++ b/findbugs/src/test/java/edu/umd/cs/findbugs/detect/FindUnsatisfiedObligationTest.java @@ -0,0 +1,22 @@ +package edu.umd.cs.findbugs.detect; + +import static org.junit.Assert.assertThat; + +import static org.hamcrest.core.Is.is; + +import static org.hamcrest.collection.IsEmptyIterable.*; +import org.junit.Test; + +import edu.umd.cs.findbugs.AbstractIntegrationTest; + +public class FindUnsatisfiedObligationTest extends AbstractIntegrationTest { + /** + * @see GitHub + * issue + */ + @Test + public void testIssue60() { + performAnalysis("Issue60.class"); + assertThat(getBugCollection(), is(emptyIterable())); + } +} diff --git a/findbugsTestCases/src/java/Issue60.java b/findbugsTestCases/src/java/Issue60.java new file mode 100644 index 00000000000..b79f1b8f447 --- /dev/null +++ b/findbugsTestCases/src/java/Issue60.java @@ -0,0 +1,22 @@ +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Properties; +import java.util.stream.Stream; + +public class Issue60 { + + public static void create(URL url) { + try (InputStream in = url.openStream()) { + Properties p1 = new Properties(); + p1.load(in); + } catch (IOException e) { + } + } + + public Stream keys() { + return Stream. of() + .flatMap(p -> p.stringPropertyNames().stream()); + } + +}