Skip to content

Commit 46db478

Browse files
committed
FirefoxOptions: be wary of numbers
JSON decoders normally return numbers as Long instances, but this isn't always the case. Apparently.
1 parent 4b5a88d commit 46db478

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

java/client/src/org/openqa/selenium/firefox/FirefoxOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ static FirefoxOptions fromJsonMap(Map<String, Object> map) throws IOException {
120120
Object value = entry.getValue();
121121
if (value instanceof Boolean) {
122122
options.addPreference(entry.getKey(), (Boolean) value);
123-
} else if (value instanceof Integer) {
124-
options.addPreference(entry.getKey(), (Integer) value);
123+
} else if (value instanceof Integer || value instanceof Long) {
124+
options.addPreference(entry.getKey(), ((Number) value).intValue());
125125
} else if (value instanceof String) {
126126
options.addPreference(entry.getKey(), (String) value);
127127
} else {
@@ -212,7 +212,7 @@ public FirefoxOptions setBinary(String path) {
212212
* useful when actually starting firefox.
213213
*/
214214
public FirefoxBinary getBinary() {
215-
return getBinaryOrNull().orElseGet(() -> new FirefoxBinary());
215+
return getBinaryOrNull().orElseGet(FirefoxBinary::new);
216216
}
217217

218218
public Optional<FirefoxBinary> getBinaryOrNull() {

0 commit comments

Comments
 (0)