apache/hadoop · error · IllegalArgumentException

{} is not boolean value

Error message

{} is not boolean value

What it means

The DFS_NAMENODE_LOCK_DETAILED_METRICS_KEY case of reconfigureFSNamesystemLockMetricsParameters requires dfs.namenode.lock.detailed-metrics.enabled to be null (reset to default) or case-insensitively 'true'/'false'; anything else throws IllegalArgumentException('<newVal> is not boolean value'), which the surrounding catch then wraps into a ReconfigurationException for the caller.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:2781

    try {
      int newSetting = adjustNewVal(
          DFS_NAMENODE_BLOCKPLACEMENTPOLICY_MIN_BLOCKS_FOR_WRITE_DEFAULT, newValue);
      namesystem.getBlockManager().setMinBlocksForWrite(newSetting);
      return String.valueOf(newSetting);
    } catch (IllegalArgumentException e) {
      throw new ReconfigurationException(property, newValue, getConf().get(property), e);
    }
  }

  private String reconfigureFSNamesystemLockMetricsParameters(final String property,
      final String newVal) throws ReconfigurationException {
    String result;
    try {
      switch (property) {
      case DFS_NAMENODE_LOCK_DETAILED_METRICS_KEY: {
        if (newVal != null && !newVal.equalsIgnoreCase("true") &&
            !newVal.equalsIgnoreCase("false")) {
          throw new IllegalArgumentException(newVal + " is not boolean value");
        }
        boolean enable = (newVal == null ?
            DFS_NAMENODE_LOCK_DETAILED_METRICS_DEFAULT : Boolean.parseBoolean(newVal));
        result = Boolean.toString(enable);
        namesystem.setMetricsEnabled(enable);
        break;
      }
      case DFS_NAMENODE_READ_LOCK_REPORTING_THRESHOLD_MS_KEY: {
        long readLockReportingThresholdMs = (newVal == null ?
            DFS_NAMENODE_READ_LOCK_REPORTING_THRESHOLD_MS_DEFAULT : Long.parseLong(newVal));
        result = Long.toString(readLockReportingThresholdMs);
        namesystem.setReadLockReportingThresholdMs(readLockReportingThresholdMs);
        break;
      }
      case DFS_NAMENODE_WRITE_LOCK_REPORTING_THRESHOLD_MS_KEY: {
        long writeLockReportingThresholdMs = (newVal == null ?
            DFS_NAMENODE_WRITE_LOCK_REPORTING_THRESHOLD_MS_DEFAULT : Long.parseLong(newVal));
        result = Long.toString(writeLockReportingThresholdMs);

View on GitHub (pinned to 2add963021)

Solutions

  1. Use exactly true or false (case-insensitive, no whitespace): `-set dfs.namenode.lock.detailed-metrics.enabled=true`
  2. Trim and validate variables in automation before sending
  3. Pair it with the threshold keys (read/write lock reporting threshold-ms), which must be plain longs
  4. After enabling, watch the new FSNamesystem lock metrics via the NN JMX

Example fix

# before
hdfs dfsadmin -reconfig namenode nn1:8020 -set dfs.namenode.lock.detailed-metrics.enabled=1

# after
hdfs dfsadmin -reconfig namenode nn1:8020 -set dfs.namenode.lock.detailed-metrics.enabled=true
Defensive patterns

Strategy: validation

Validate before calling

V=$(echo "$LOCK_METRICS" | tr -d '[:space:]')
case "${V,,}" in true|false) ;; *) echo "need true|false"; exit 1;; esac
hdfs dfsadmin -reconfig namenode nn1:8020 -set dfs.namenode.lock.detailed-metrics.enabled=$V

Type guard

static boolean isBooleanLiteral(String s) {
  return "true".equalsIgnoreCase(s) || "false".equalsIgnoreCase(s);
}

Try / catch

catch (ReconfigurationException e) {
  if (e.getCause() instanceof IllegalArgumentException
      && e.getCause().getMessage().contains("not boolean")) {
    // retry with exactly true/false
  }
}

Prevention

When it happens

Trigger: `hdfs dfsadmin -reconfig namenode <addr> -set dfs.namenode.lock.detailed-metrics.enabled=<not true/false>` - e.g. 'yes', '1', 'enable', 'TRUE ' with whitespace.

Common situations: Enabling detailed NameNode lock metrics for latency debugging with loose boolean spellings; config management writing 'True ' with a trailing space.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/6021031844592fd9. Report an issue: GitHub.