apache/flink · warning · IllegalStateException
Hostname ${originalHostname} starts with a ${DOMAIN_SEPARATO
Error message
Hostname ${originalHostname} starts with a ${DOMAIN_SEPARATOR} What it means
HadoopBlockLocation.getHostName strips the first DNS label off hostnames that contain the domain separator ('.'), so 'host.example.com' becomes 'host'. Before stripping it verifies the string is not an IPv4 address and that the separator is not the first character; a leading '.' means the value is malformed for this operation, so an IllegalStateException is thrown.
Source
Thrown at flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/fs/hdfs/HadoopBlockLocation.java:117
* @param originalHostname the original hostname, possibly an FQDN
* @return the stripped hostname without the domain suffix
*/
private static String stripHostname(final String originalHostname) {
// Check if the hostname domains the domain separator character
final int index = originalHostname.indexOf(DOMAIN_SEPARATOR);
if (index == -1) {
return originalHostname;
}
// Make sure we are not stripping an IPv4 address
final Matcher matcher = IPV4_PATTERN.matcher(originalHostname);
if (matcher.matches()) {
return originalHostname;
}
if (index == 0) {
throw new IllegalStateException(
"Hostname " + originalHostname + " starts with a " + DOMAIN_SEPARATOR);
}
return originalHostname.substring(0, index);
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Fix the underlying filesystem/storage to return well-formed hostnames in block locations
- Sanitize/normalize hostname strings before they reach block-location queries if you control the Hadoop filesystem shim
- If the file layout does not need block locations, avoid getFileBlockLocations on this path
Defensive patterns
Strategy: validation
Validate before calling
String host = blockLocation.getHostName(); // only if you control the source
// guard inputs to HadoopBlockLocation
if (host == null || host.startsWith(".")) {
// reject/normalize malformed host before constructing block locations
} Try / catch
try {
name = blockLocation.getHost();
} catch (IllegalStateException e) {
// malformed hostname metadata; fall back to raw name if available or skip locality
} Prevention
- Return well-formed hostnames from custom Hadoop filesystem implementations
- Test block-location handling against your actual storage backend
- Never construct hostnames with leading dots in test fixtures or shims
When it happens
Trigger: Calling getHost() on a HadoopBlockLocation whose underlying Hadoop BlockLocation reports a host string beginning with '.' (index == 0 for the DOMAIN_SEPARATOR).
Common situations: Odd or malformed block-location metadata returned by an HDFS NameNode or a non-standard Hadoop-compatible filesystem (e.g. some S3/mock connectors returning '.host' style names); custom Hadoop filesystem implementations with unusual location reporting.
Related errors
- The given offset is not contained in the any block.
- file is not an instance of DistributedFileStatus
- Input opening request timed out. Opener was {} alive. Stack
- Output path could not be initialized.
- Output directory could not be created.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/fbccdddc301de5f2.
Report an issue: GitHub.