Skip to content

Commit a34cb31

Browse files
authored
Upgrade to Spotbugs 6.0.15 (#1398)
* Exclude CT_CONSTRUCTOR_THROW * Exclude PA_PUBLIC_PRIMITIVE_ATTRIBUTE * Add assertion to handle NP warning JAVA-5480
1 parent 790185f commit a34cb31

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ buildscript {
2525
}
2626
dependencies {
2727
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:7.0.0'
28-
classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.13"
28+
classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.15"
2929
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.1.2'
3030

3131
// Scala plugins

config/spotbugs/exclude.xml

+20-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,29 @@
1414
~ limitations under the License.
1515
-->
1616

17-
<!-- See https://spotbugs.readthedocs.io/en/latest/filter.html#rank
17+
<!--
18+
To determine the rank of a newly-detected bug that you would like to exclude,
19+
run spotbugsMain task with xml.enabled, then examine the XML report in
20+
<module>/build/reports/spotbugs/main.xml, where the rankings are
21+
included as part of the report, e.g.
22+
23+
<BugInstance type="PA_PUBLIC_PRIMITIVE_ATTRIBUTE" priority="2" rank="16" ...
24+
25+
See https://spotbugs.readthedocs.io/en/latest/filter.html#rank
1826
for the mapping from SpotBugs rank to verbal labels.
1927
-->
2028
<FindBugsFilter>
29+
<Match>
30+
<!-- MongoDB status: "No Fix Needed", SpotBugs rank: 16 -->
31+
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
32+
</Match>
33+
34+
<Match>
35+
<!-- MongoDB status: "No Fix Needed", SpotBugs rank: 16 -->
36+
<Class name="com.mongodb.internal.connection.tlschannel.impl.BufferHolder"/>
37+
<Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE"/>
38+
</Match>
39+
2140
<Match>
2241
<!-- MongoDB status: "No Fix Needed", SpotBugs rank: 18 -->
2342
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>

driver-core/src/main/com/mongodb/internal/connection/AbstractMultiServerCluster.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.concurrent.ConcurrentHashMap;
3939
import java.util.concurrent.ConcurrentMap;
4040

41+
import static com.mongodb.assertions.Assertions.assertNotNull;
4142
import static com.mongodb.assertions.Assertions.isTrue;
4243
import static com.mongodb.connection.ClusterConnectionMode.MULTIPLE;
4344
import static com.mongodb.connection.ClusterType.UNKNOWN;
@@ -234,7 +235,7 @@ private boolean handleReplicaSetMemberChanged(final ServerDescription newDescrip
234235
}
235236

236237
if (replicaSetName == null) {
237-
replicaSetName = newDescription.getSetName();
238+
replicaSetName = assertNotNull(newDescription.getSetName());
238239
}
239240

240241
if (!replicaSetName.equals(newDescription.getSetName())) {

0 commit comments

Comments
 (0)