diff --git a/hudi-common/src/main/java/org/apache/hudi/common/config/TypedProperties.java b/hudi-common/src/main/java/org/apache/hudi/common/config/TypedProperties.java index 49db9b23a..2688e6454 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/config/TypedProperties.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/config/TypedProperties.java @@ -23,7 +23,6 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.Properties; -import java.util.Set; import java.util.stream.Collectors; /** @@ -44,27 +43,22 @@ public class TypedProperties extends Properties implements Serializable { } private void checkKey(String property) { - if (!keyExists(property)) { + if (!containsKey(property)) { throw new IllegalArgumentException("Property " + property + " not found"); } } - private boolean keyExists(String property) { - Set keys = super.stringPropertyNames(); - return keys.contains(property); - } - public String getString(String property) { checkKey(property); return getProperty(property); } public String getString(String property, String defaultValue) { - return keyExists(property) ? getProperty(property) : defaultValue; + return containsKey(property) ? getProperty(property) : defaultValue; } public List getStringList(String property, String delimiter, List defaultVal) { - if (!keyExists(property)) { + if (!containsKey(property)) { return defaultVal; } return Arrays.stream(getProperty(property).split(delimiter)).map(String::trim).collect(Collectors.toList()); @@ -76,7 +70,7 @@ public class TypedProperties extends Properties implements Serializable { } public int getInteger(String property, int defaultValue) { - return keyExists(property) ? Integer.parseInt(getProperty(property)) : defaultValue; + return containsKey(property) ? Integer.parseInt(getProperty(property)) : defaultValue; } public long getLong(String property) { @@ -85,7 +79,7 @@ public class TypedProperties extends Properties implements Serializable { } public long getLong(String property, long defaultValue) { - return keyExists(property) ? Long.parseLong(getProperty(property)) : defaultValue; + return containsKey(property) ? Long.parseLong(getProperty(property)) : defaultValue; } public boolean getBoolean(String property) { @@ -94,7 +88,7 @@ public class TypedProperties extends Properties implements Serializable { } public boolean getBoolean(String property, boolean defaultValue) { - return keyExists(property) ? Boolean.parseBoolean(getProperty(property)) : defaultValue; + return containsKey(property) ? Boolean.parseBoolean(getProperty(property)) : defaultValue; } public double getDouble(String property) { @@ -103,6 +97,6 @@ public class TypedProperties extends Properties implements Serializable { } public double getDouble(String property, double defaultValue) { - return keyExists(property) ? Double.parseDouble(getProperty(property)) : defaultValue; + return containsKey(property) ? Double.parseDouble(getProperty(property)) : defaultValue; } }