Skip to content

Commit 9a52775

Browse files
committed
[java] Adding exceptions to spotbugs config
1 parent 25564bd commit 9a52775

File tree

3 files changed

+46
-30
lines changed

3 files changed

+46
-30
lines changed

java/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spotbugs_config(
4141
name = "spotbugs-config",
4242
effort = "default",
4343
exclude_filter = "spotbugs-excludes.xml",
44-
fail_on_warning = False,
44+
fail_on_warning = True,
4545
visibility = [
4646
"//visibility:public",
4747
],

java/spotbugs-excludes.xml

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<FindBugsFilter
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xmlns="https://github.com/spotbugs/filter/3.0.0"
5-
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="https://github.com/spotbugs/filter/3.0.0"
5+
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
66

77
<Match>
8-
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
8+
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC,EI_EXPOSE_REP,EI_EXPOSE_REP2,EI_EXPOSE_BUF2"/>
99
</Match>
1010

1111
<Match>
12-
<Class name="com.thoughtworks.selenium.InternalSelenseTestBase"/>
13-
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
12+
<Bug pattern="URF_UNREAD_FIELD,URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD,SS_SHOULD_BE_STATIC"/>
13+
</Match>
14+
15+
<Match>
16+
<Bug pattern="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS"/>
17+
</Match>
18+
19+
<Match>
20+
<Bug code="RCN,MS,DCN,UwF"/>
21+
</Match>
22+
23+
<Match>
24+
<Class name="~.*\.*Test"/>
25+
</Match>
26+
27+
<Match>
28+
<Package name="^com.thoughtworks.selenium\S*"/>
1429
</Match>
1530

1631
<Match>
@@ -29,7 +44,7 @@
2944
</Match>
3045

3146
<Match>
32-
<Class name="org.openqa.selenium.docker.v1_40.PullImage"/>
47+
<Class name="org.openqa.selenium.docker.v1_41.PullImage"/>
3348
<Bug pattern="DE_MIGHT_IGNORE"/>
3449
</Match>
3550

@@ -73,11 +88,6 @@
7388
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
7489
</Match>
7590

76-
<Match>
77-
<Class name="~org.openqa.selenium.grid.data..*SessionResponse"/>
78-
<Bug pattern="EI_EXPOSE_REP"/>
79-
</Match>
80-
8191
<Match>
8292
<Class name="org.openqa.selenium.grid.log.LoggingFlags"/>
8393
<Bug pattern="URF_UNREAD_FIELD"/>
@@ -140,23 +150,23 @@
140150
</Match>
141151

142152
<Match>
143-
<Class name="org.openqa.selenium.remote.http.BinaryMessage"/>
144-
<Bug pattern="EI_EXPOSE_REP"/>
153+
<Class name="org.openqa.selenium.safari.SafariDriverService"/>
154+
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/>
145155
</Match>
146156

147157
<Match>
148-
<Class name="~org.openqa.selenium.remote.internal.HttpClientTestBase.*"/>
149-
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
158+
<Class name="org.openqa.selenium.testing.Pages"/>
159+
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
150160
</Match>
151161

152162
<Match>
153-
<Class name="org.openqa.selenium.safari.SafariDriverService"/>
154-
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/>
163+
<Class name="org.openqa.selenium.remote.WebDriverFixture"/>
164+
<Bug pattern="WMI_WRONG_MAP_ITERATOR"/>
155165
</Match>
156166

157167
<Match>
158-
<Class name="org.openqa.selenium.testing.Pages"/>
159-
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
168+
<Class name="org.openqa.selenium.remote.internal.HttpClientTestBase"/>
169+
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
160170
</Match>
161171

162172
<Match>

java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
import com.google.common.annotations.VisibleForTesting;
2121
import com.google.common.collect.ImmutableMap;
2222
import com.google.common.collect.ImmutableSet;
23-
import dev.failsafe.Failsafe;
24-
import dev.failsafe.RetryPolicy;
23+
2524
import org.openqa.selenium.Beta;
2625
import org.openqa.selenium.Capabilities;
2726
import org.openqa.selenium.HealthCheckFailedException;
@@ -81,6 +80,9 @@
8180
import org.openqa.selenium.remote.tracing.Tracer;
8281
import org.openqa.selenium.status.HasReadyState;
8382

83+
import dev.failsafe.Failsafe;
84+
import dev.failsafe.RetryPolicy;
85+
8486
import java.io.Closeable;
8587
import java.io.UncheckedIOException;
8688
import java.net.URI;
@@ -493,21 +495,25 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Sess
493495
Map<String, EventAttributeValue> attributeMap = new HashMap<>();
494496
try {
495497
attributeMap.put(AttributeKey.LOGGER_CLASS.getKey(),
496-
EventAttribute.setValue(getClass().getName()));
498+
EventAttribute.setValue(getClass().getName()));
497499

498-
attributeMap.put("request.payload", EventAttribute.setValue(request.getDesiredCapabilities().toString()));
500+
attributeMap.put("request.payload",
501+
EventAttribute.setValue(request.getDesiredCapabilities().toString()));
499502
String sessionReceivedMessage = "Session request received by the Distributor";
500503
span.addEvent(sessionReceivedMessage, attributeMap);
501-
LOG.info(String.format("%s: \n %s", sessionReceivedMessage, request.getDesiredCapabilities()));
504+
LOG.info(String.format("%s: %n %s",
505+
sessionReceivedMessage,
506+
request.getDesiredCapabilities()));
502507

503508
// If there are no capabilities at all, something is horribly wrong
504509
if (request.getDesiredCapabilities().isEmpty()) {
505510
SessionNotCreatedException exception =
506511
new SessionNotCreatedException("No capabilities found in session request payload");
507512
EXCEPTION.accept(attributeMap, exception);
508513
attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),
509-
EventAttribute.setValue("Unable to create session. No capabilities found: " +
510-
exception.getMessage()));
514+
EventAttribute.setValue(
515+
"Unable to create session. No capabilities found: " +
516+
exception.getMessage()));
511517
span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);
512518
return Either.left(exception);
513519
}
@@ -528,7 +534,7 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Sess
528534
SlotId selectedSlot = reserveSlot(request.getRequestId(), caps);
529535
if (selectedSlot == null) {
530536
LOG.info(
531-
String.format("Unable to find a free slot for request %s. \n %s ",
537+
String.format("Unable to find a free slot for request %s. %n %s ",
532538
request.getRequestId(),
533539
caps));
534540
retry = true;
@@ -558,7 +564,7 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Sess
558564
String sessionCreatedMessage = "Session created by the Distributor";
559565
span.addEvent(sessionCreatedMessage, attributeMap);
560566
LOG.info(
561-
String.format("%s. Id: %s \n Caps: %s", sessionCreatedMessage, sessionId, sessionCaps));
567+
String.format("%s. Id: %s %n Caps: %s", sessionCreatedMessage, sessionId, sessionCaps));
562568

563569
return Either.right(response);
564570
} catch (SessionNotCreatedException e) {

0 commit comments

Comments
 (0)