apache/hadoop · error · IllegalStateException
value cannot be blank
Error message
value cannot be blank
What it means
StorageSize.parse(String) converts a size literal like "1000MB" into a StorageUnit + double pair. Its first step is checkState(isNotBlank(value), "value cannot be blank"), so null, empty, or whitespace-only input fails immediately. Note the exception type is IllegalStateException (the checkState helper throws ISE), not IllegalArgumentException as for later format problems.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/StorageSize.java:46
public class StorageSize {
private final StorageUnit unit;
private final double value;
/**
* Constucts a Storage Measure, which contains the value and the unit of
* measure.
*
* @param unit - Unit of Measure
* @param value - Numeric value.
*/
public StorageSize(StorageUnit unit, double value) {
this.unit = unit;
this.value = value;
}
private static void checkState(boolean state, String errorString){
if(!state) {
throw new IllegalStateException(errorString);
}
}
public static StorageSize parse(String value) {
checkState(isNotBlank(value), "value cannot be blank");
String sanitizedValue = value.trim().toLowerCase(Locale.ENGLISH);
StorageUnit parsedUnit = null;
for (StorageUnit unit : StorageUnit.values()) {
if (sanitizedValue.endsWith(unit.getShortName()) ||
sanitizedValue.endsWith(unit.getLongName()) ||
sanitizedValue.endsWith(unit.getSuffixChar())) {
parsedUnit = unit;
break;
}
}
if (parsedUnit == null) {
throw new IllegalArgumentException(value + " is not in expected format." +View on GitHub (pinned to 2add963021)
Solutions
- Set a valid default with unit for the config key, e.g. conf.get(key, "128MB")
- Null/blank-check the string before calling StorageSize.parse() and fail with a message naming the key
- Fix the property name or the substitution expression so it cannot resolve to null/empty
Example fix
// before
StorageSize size = StorageSize.parse(conf.get("some.size.key")); // ISE if unset
// after
String raw = conf.get("some.size.key", "128MB");
if (StringUtils.isBlank(raw)) {
throw new IllegalArgumentException("some.size.key must be set, e.g. 128MB");
}
StorageSize size = StorageSize.parse(raw); Defensive patterns
Strategy: validation
Validate before calling
String raw = conf.get(key, defaultWithUnit); // e.g. default "128MB"
if (StringUtils.isBlank(raw)) {
throw new IllegalArgumentException(key + " must be a non-empty <number><unit> value");
}
StorageSize size = StorageSize.parse(raw); Try / catch
try {
size = StorageSize.parse(raw);
} catch (IllegalStateException e) {
// blank input -> fail with the config key name for actionable context
throw new IllegalArgumentException(key + " is unset/empty; expected e.g. 128MB", e);
} Prevention
- Always supply a unit-bearing default when reading size-typed config keys
- Add config sanity checks at service startup rather than at first use
- Lint configs for empty <value/> elements in CI
When it happens
Trigger: StorageSize.parse(null), parse(""), or parse(" "); almost always the argument came straight from an unset or empty configuration property (conf.get(key) returning null or an empty string).
Common situations: A newly introduced size-typed config key with no default in the XML; a property defined with an empty <value/>; variable substitution (${...}) resolving to empty; a typo'd key name making conf.get() return null.
Related errors
- ${value} is not in expected format.Expected format is <numbe
- Bad configuration of hadoop.security.key.provider.path at ${
- Invalid <aclSpec> :
- Invalid type of acl in <aclSpec> :
- Bad HTML quoting for {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c48d4e1322dbe40a.
Report an issue: GitHub.