diff --git a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java index a47ca5ef1ba11..6988f6aa51c63 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java @@ -81,7 +81,7 @@ public FirefoxOptions(Capabilities source) { if (rawOptions != null) { // If `source` contains the keys we care about, then make sure they're good. Require.stateCondition(rawOptions instanceof Map, "Expected options to be a map: %s", rawOptions); - Map sourceOptions = (Map) rawOptions; + @SuppressWarnings("unchecked") Map sourceOptions = (Map) rawOptions; Map options = new TreeMap<>(); for (Keys key : Keys.values()) { key.amend(sourceOptions, options); @@ -261,9 +261,8 @@ public FirefoxOptions addPreference(String key, Object value) { Object rawPrefs = firefoxOptions.getOrDefault(Keys.PREFS.key(), new HashMap<>()); Require.stateCondition(rawPrefs instanceof Map, "Prefs are of unexpected type: %s", rawPrefs); - Map newPrefs = new TreeMap<>(); @SuppressWarnings("unchecked") Map prefs = (Map) rawPrefs; - newPrefs.putAll(prefs); + Map newPrefs = new TreeMap<>(prefs); newPrefs.put(key, value); return setFirefoxOption(Keys.PREFS, Collections.unmodifiableMap(newPrefs));