Skip to content

Commit 06b00a9

Browse files
committed
Fix spotbugs tests
1 parent ebeee43 commit 06b00a9

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

java/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ java_library(
3838

3939
spotbugs_config(
4040
name = "spotbugs-config",
41-
effort = "default",
4241
exclude_filter = "spotbugs-excludes.xml",
4342
fail_on_warning = True,
4443
visibility = [

java/spotbugs-excludes.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<Bug code="RCN,MS,DCN,UwF,THROWS,SSD"/>
2121
</Match>
2222

23+
<Match>
24+
<!-- Warnings about finalizer attacks are really not worth addressing -->
25+
<Bug code="CT"/>
26+
</Match>
27+
2328
<Match>
2429
<Class name="~.*\.*Test"/>
2530
</Match>
@@ -139,7 +144,7 @@
139144
<Class name="org.openqa.selenium.json.JsonInputIterator"/>
140145
<Bug pattern="IT_NO_SUCH_ELEMENT"/>
141146
</Match>
142-
147+
143148
<Match>
144149
<Class name="org.openqa.selenium.net.NetworkUtils"/>
145150
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>

java/src/org/openqa/selenium/chrome/ChromeDriver.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ public ChromeDriver(ChromeDriverService service, ChromeOptions options) {
8585

8686
public ChromeDriver(
8787
ChromeDriverService service, ChromeOptions options, ClientConfig clientConfig) {
88-
super(generateExecutor(service, options, clientConfig), options, ChromeOptions.CAPABILITY);
89-
casting = new AddHasCasting().getImplementation(getCapabilities(), getExecuteMethod());
90-
cdp = new AddHasCdp().getImplementation(getCapabilities(), getExecuteMethod());
88+
super(
89+
generateExecutor(service, options, clientConfig),
90+
options,
91+
ChromeOptions.CAPABILITY,
92+
(caps, method) -> new AddHasCasting().getImplementation(caps, method),
93+
(caps, method) -> new AddHasCdp().getImplementation(caps, method));
9194
}
9295

9396
private static ChromeDriverCommandExecutor generateExecutor(

java/src/org/openqa/selenium/chromium/ChromiumDriver.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Map;
2929
import java.util.Optional;
3030
import java.util.Set;
31+
import java.util.function.BiFunction;
3132
import java.util.function.Predicate;
3233
import java.util.function.Supplier;
3334
import java.util.logging.Level;
@@ -62,6 +63,7 @@
6263
import org.openqa.selenium.logging.EventType;
6364
import org.openqa.selenium.logging.HasLogEvents;
6465
import org.openqa.selenium.remote.CommandExecutor;
66+
import org.openqa.selenium.remote.ExecuteMethod;
6567
import org.openqa.selenium.remote.FileDetector;
6668
import org.openqa.selenium.remote.RemoteWebDriver;
6769
import org.openqa.selenium.remote.html5.RemoteLocationContext;
@@ -106,14 +108,20 @@ public class ChromiumDriver extends RemoteWebDriver
106108
private final Map<Integer, ScriptKey> scriptKeys = new HashMap<>();
107109

108110
protected ChromiumDriver(
109-
CommandExecutor commandExecutor, Capabilities capabilities, String capabilityKey) {
111+
CommandExecutor commandExecutor,
112+
Capabilities capabilities,
113+
String capabilityKey,
114+
BiFunction<Capabilities, ExecuteMethod, HasCasting> createCasting,
115+
BiFunction<Capabilities, ExecuteMethod, HasCdp> createCdp) {
110116
super(commandExecutor, capabilities);
111117
locationContext = new RemoteLocationContext(getExecuteMethod());
112118
webStorage = new RemoteWebStorage(getExecuteMethod());
113119
permissions = new AddHasPermissions().getImplementation(getCapabilities(), getExecuteMethod());
114120
networkConditions =
115121
new AddHasNetworkConditions().getImplementation(getCapabilities(), getExecuteMethod());
116122
launch = new AddHasLaunchApp().getImplementation(getCapabilities(), getExecuteMethod());
123+
casting = createCasting.apply(getCapabilities(), getExecuteMethod());
124+
cdp = createCdp.apply(getCapabilities(), getExecuteMethod());
117125

118126
HttpClient.Factory factory = HttpClient.Factory.createDefault();
119127
Capabilities originalCapabilities = super.getCapabilities();

java/src/org/openqa/selenium/edge/EdgeDriver.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ public EdgeDriver(EdgeDriverService service, EdgeOptions options) {
5757
}
5858

5959
public EdgeDriver(EdgeDriverService service, EdgeOptions options, ClientConfig clientConfig) {
60-
super(generateExecutor(service, options, clientConfig), options, EdgeOptions.CAPABILITY);
61-
casting = new AddHasCasting().getImplementation(getCapabilities(), getExecuteMethod());
62-
cdp = new AddHasCdp().getImplementation(getCapabilities(), getExecuteMethod());
60+
super(
61+
generateExecutor(service, options, clientConfig),
62+
options,
63+
EdgeOptions.CAPABILITY,
64+
(caps, method) -> new AddHasCasting().getImplementation(caps, method),
65+
(caps, method) -> new AddHasCdp().getImplementation(caps, method));
6366
}
6467

6568
private static EdgeDriverCommandExecutor generateExecutor(

java/src/org/openqa/selenium/firefox/ProfilesIni.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ protected File locateAppDataDirectory(Platform os) {
136136
appData =
137137
new File(
138138
MessageFormat.format(
139-
"{0}/Library/Application Support/Firefox", System.getenv("HOME")));
139+
"{0}/Library/Application Support/Firefox", System.getProperty("user.home")));
140140

141141
} else {
142-
appData = new File(MessageFormat.format("{0}/.mozilla/firefox", System.getenv("HOME")));
142+
appData = new File(MessageFormat.format("{0}/.mozilla/firefox", System.getProperty("user.home")));
143143
}
144144

145145
if (!appData.exists()) {

0 commit comments

Comments
 (0)