Skip to content


8287924: Avoid redundant HashMap.containsKey call in EnvHelp.mapToHas…
Browse files Browse the repository at this point in the history

Reviewed-by: sspitsyn, cjplummer
  • Loading branch information
Andrey Turbanov committed Jun 9, 2022
1 parent d482d7f commit 900d967
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
import com.sun.jmx.mbeanserver.GetPropertyAction;

public class EnvHelp {

Expand Down Expand Up @@ -733,11 +731,11 @@ else if (stringBoolean.equalsIgnoreCase("false"))
* it removes all the 'null' values from the map.
public static <K, V> Hashtable<K, V> mapToHashtable(Map<K, V> map) {
HashMap<K, V> m = new HashMap<K, V>(map);
if (m.containsKey(null)) m.remove(null);
HashMap<K, V> m = new HashMap<>(map);
for (Iterator<?> i = m.values().iterator(); i.hasNext(); )
if ( == null) i.remove();
return new Hashtable<K, V>(m);
return new Hashtable<>(m);

Expand Down

1 comment on commit 900d967

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.