szetszwo commented on code in PR #6549: URL: https://github.com/apache/hadoop/pull/6549#discussion_r1523650714
########## hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FsImageValidation.java: ########## @@ -77,6 +79,35 @@ public class FsImageValidation { static final String FS_IMAGE = "FS_IMAGE"; + /** + * Use an environment variable "PRINT_ERROR" to enable/disable printing error messages. + * The default is true + */ + static final boolean PRINT_ERROR; + + static { + PRINT_ERROR = getEnvBoolean("PRINT_ERROR", true); + } + + /** + * @return the boolean value of an environment property. + * If the environment property is not set or cannot be parsed as a boolean, + * return the default value. + */ + static boolean getEnvBoolean(String property, boolean defaultValue) { + final String env = System.getenv().get(property); + final boolean setToNonDefault = ("" + !defaultValue).equalsIgnoreCase(env); + // default | setToNonDefault | value + // --------------------------------- + // true | true | false + // true | false | true + // false | true | true + // false | false | false + final boolean value = defaultValue != setToNonDefault; Review Comment: `getEnv` does not care about the default value. This method `getEnvBoolean` will handle default as specified in the javadoc ```java * If the environment property is not set or cannot be parsed as a boolean, * return the default value. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org