Skip to content

Commit

Permalink
Reproduce reported problem, and solve it by upgrading BCEL to 6.1 (#69)
Browse files Browse the repository at this point in the history
* refs #60: reproduce reported problem

* refs #60: throw AssertionError when bugReporter has Error

* refs #60: confirm that BCEL 6.1 can solve this problem

* refs #60: use BCEL 6.1-SNAPSHOT

* refs #60: add missing dependency

* refs #60: include bcel 6.1 into built artifact
  • Loading branch information
KengoTODA authored Jan 22, 2017
1 parent f6fe13e commit d90c167
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion eclipsePlugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Bundle-Version: 3.1.0.qualifier
Bundle-ClassPath: findbugs-plugin.jar,
lib/jsr305.jar,
lib/annotations.jar,
lib/bcel-6.0.jar,
lib/bcel-6.1-20161207.023659-9.jar,
lib/dom4j-1.6.1.jar,
lib/jaxen-1.1.6.jar,
lib/jFormatString.jar,
Expand Down
2 changes: 1 addition & 1 deletion eclipsePlugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
includedLibs(project(path:':findbugs', configuration:'annotations')) {
transitive = false
}
includedLibs 'org.apache.bcel:bcel:6.0'
includedLibs fileTree(dir: '../findbugs/lib', include: 'bcel-6.1*.jar')
includedLibs 'org.ow2.asm:asm-debug-all:6.0_ALPHA'

embeddedLibs(project(':findbugs')) {
Expand Down
4 changes: 1 addition & 3 deletions eclipsePlugin/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bin.includes = FindBugs.png,\
META-INF/,\
spotbugs.png,\
lib/annotations.jar,\
lib/bcel.jar,\
lib/bcel-6.1-20161207.023659-9.jar,\
lib/commons-lang-2.6.jar,\
lib/dom4j-1.6.1.jar,\
lib/jFormatString.jar,\
Expand Down Expand Up @@ -51,5 +51,3 @@ src.includes = FindBugs.png,\
jars.compile.order = findbugs-plugin.jar
source.findbugs-plugin.jar = src/
output.findbugs-plugin.jar = bin_eclipse/


6 changes: 4 additions & 2 deletions findbugs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ configurations {
}

dependencies {
compile 'org.apache.bcel:bcel:6.0'
compile 'org.ow2.asm:asm-debug-all:6.0_ALPHA'
compile 'net.jcip:jcip-annotations:1.0'

Expand All @@ -46,13 +45,16 @@ tasks.withType(Jar).all {
// Manually define what goes into the default jar, since it's not only main sourceset
jar {
from sourceSets.main.output
from zipTree("$projectDir/lib/bcel-6.1-20161207.023659-9.jar").matching {
exclude 'META-INF/**'
}

baseName 'spotbugs' // Needed until we rename the directory

manifest {
attributes 'Main-Class': 'edu.umd.cs.findbugs.LaunchAppropriateUI',
'Bundle-Version': project.version,
'Class-Path': 'bcel-6.0.jar dom4j-1.6.1.jar jaxen-1.1.6.jar asm-debug-all-6.0_ALPHA.jar jsr305.jar jFormatString.jar commons-lang-2.6.jar'
'Class-Path': 'dom4j-1.6.1.jar jaxen-1.1.6.jar asm-debug-all-6.0_ALPHA.jar jsr305.jar jFormatString.jar commons-lang-2.6.jar'
}
}

Expand Down
Binary file added findbugs/lib/bcel-6.1-20161207.023659-9.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ protected void performAnalysis(@SlashedClassName final String... analyzeMe) {
} catch (final IOException | InterruptedException e) {
fail("Analysis failed with exception; " + e.getMessage());
}
if (! bugReporter.getQueuedErrors().isEmpty()) {
AssertionError assertionError = new AssertionError("Analysis failed with exception. Check stderr for detail.");
bugReporter.getQueuedErrors().stream()
.map(error -> error.getCause())
.forEach(assertionError::addSuppressed);
throw assertionError;
}
}

private static final class CountMatcher<T> extends BaseMatcher<Iterable<T>> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <a href="https://github.com/spotbugs/spotbugs/issues/60">GitHub
* issue</a>
*/
@Test
public void testIssue60() {
performAnalysis("Issue60.class");
assertThat(getBugCollection(), is(emptyIterable()));
}
}
22 changes: 22 additions & 0 deletions findbugsTestCases/src/java/Issue60.java
Original file line number Diff line number Diff line change
@@ -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<String> keys() {
return Stream.<Properties> of()
.flatMap(p -> p.stringPropertyNames().stream());
}

}

0 comments on commit d90c167

Please sign in to comment.