Skip to content

Commit d90c167

Browse files
authored
Reproduce reported problem, and solve it by upgrading BCEL to 6.1 (#69)
* 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
1 parent f6fe13e commit d90c167

File tree

8 files changed

+58
-7
lines changed

8 files changed

+58
-7
lines changed

eclipsePlugin/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Bundle-Version: 3.1.0.qualifier
66
Bundle-ClassPath: findbugs-plugin.jar,
77
lib/jsr305.jar,
88
lib/annotations.jar,
9-
lib/bcel-6.0.jar,
9+
lib/bcel-6.1-20161207.023659-9.jar,
1010
lib/dom4j-1.6.1.jar,
1111
lib/jaxen-1.1.6.jar,
1212
lib/jFormatString.jar,

eclipsePlugin/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies {
4444
includedLibs(project(path:':findbugs', configuration:'annotations')) {
4545
transitive = false
4646
}
47-
includedLibs 'org.apache.bcel:bcel:6.0'
47+
includedLibs fileTree(dir: '../findbugs/lib', include: 'bcel-6.1*.jar')
4848
includedLibs 'org.ow2.asm:asm-debug-all:6.0_ALPHA'
4949

5050
embeddedLibs(project(':findbugs')) {

eclipsePlugin/build.properties

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bin.includes = FindBugs.png,\
1616
META-INF/,\
1717
spotbugs.png,\
1818
lib/annotations.jar,\
19-
lib/bcel.jar,\
19+
lib/bcel-6.1-20161207.023659-9.jar,\
2020
lib/commons-lang-2.6.jar,\
2121
lib/dom4j-1.6.1.jar,\
2222
lib/jFormatString.jar,\
@@ -51,5 +51,3 @@ src.includes = FindBugs.png,\
5151
jars.compile.order = findbugs-plugin.jar
5252
source.findbugs-plugin.jar = src/
5353
output.findbugs-plugin.jar = bin_eclipse/
54-
55-

findbugs/build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ configurations {
2929
}
3030

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

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

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

5254
manifest {
5355
attributes 'Main-Class': 'edu.umd.cs.findbugs.LaunchAppropriateUI',
5456
'Bundle-Version': project.version,
55-
'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'
57+
'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'
5658
}
5759
}
5860

656 KB
Binary file not shown.

findbugs/src/test/java/edu/umd/cs/findbugs/AbstractIntegrationTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ protected void performAnalysis(@SlashedClassName final String... analyzeMe) {
138138
} catch (final IOException | InterruptedException e) {
139139
fail("Analysis failed with exception; " + e.getMessage());
140140
}
141+
if (! bugReporter.getQueuedErrors().isEmpty()) {
142+
AssertionError assertionError = new AssertionError("Analysis failed with exception. Check stderr for detail.");
143+
bugReporter.getQueuedErrors().stream()
144+
.map(error -> error.getCause())
145+
.forEach(assertionError::addSuppressed);
146+
throw assertionError;
147+
}
141148
}
142149

143150
private static final class CountMatcher<T> extends BaseMatcher<Iterable<T>> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package edu.umd.cs.findbugs.detect;
2+
3+
import static org.junit.Assert.assertThat;
4+
5+
import static org.hamcrest.core.Is.is;
6+
7+
import static org.hamcrest.collection.IsEmptyIterable.*;
8+
import org.junit.Test;
9+
10+
import edu.umd.cs.findbugs.AbstractIntegrationTest;
11+
12+
public class FindUnsatisfiedObligationTest extends AbstractIntegrationTest {
13+
/**
14+
* @see <a href="https://github.com/spotbugs/spotbugs/issues/60">GitHub
15+
* issue</a>
16+
*/
17+
@Test
18+
public void testIssue60() {
19+
performAnalysis("Issue60.class");
20+
assertThat(getBugCollection(), is(emptyIterable()));
21+
}
22+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.io.IOException;
2+
import java.io.InputStream;
3+
import java.net.URL;
4+
import java.util.Properties;
5+
import java.util.stream.Stream;
6+
7+
public class Issue60 {
8+
9+
public static void create(URL url) {
10+
try (InputStream in = url.openStream()) {
11+
Properties p1 = new Properties();
12+
p1.load(in);
13+
} catch (IOException e) {
14+
}
15+
}
16+
17+
public Stream<String> keys() {
18+
return Stream.<Properties> of()
19+
.flatMap(p -> p.stringPropertyNames().stream());
20+
}
21+
22+
}

0 commit comments

Comments
 (0)