FirefoxOptions: be wary of numbers
JSON decoders normally return numbers as Long instances, but
this isn't always the case. Apparently.
@@ -120,8 +120,8 @@ static FirefoxOptions fromJsonMap(Map<String, Object> map) throws IOException {
Object value = entry.getValue();
if (value instanceof Boolean) {
options.addPreference(entry.getKey(), (Boolean) value);
- } else if (value instanceof Integer) {
- options.addPreference(entry.getKey(), (Integer) value);
+ } else if (value instanceof Integer || value instanceof Long) {
+ options.addPreference(entry.getKey(), ((Number) value).intValue());
} else if (value instanceof String) {
options.addPreference(entry.getKey(), (String) value);
} else {
@@ -212,7 +212,7 @@ public FirefoxOptions setBinary(String path) {
* useful when actually starting firefox.
*/
public FirefoxBinary getBinary() {
- return getBinaryOrNull().orElseGet(() -> new FirefoxBinary());
+ return getBinaryOrNull().orElseGet(FirefoxBinary::new);
}
public Optional<FirefoxBinary> getBinaryOrNull() {
