{"record":{"id":"35e3301574727e0f","repo":"apache/flink","slug":"fqdn-is-null","errorCode":null,"errorMessage":"fqdn is null","messagePattern":"fqdn is null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/NetUtils.java","lineNumber":64,"sourceCode":"@Internal\npublic class NetUtils {\n\n    private static final Logger LOG = LoggerFactory.getLogger(NetUtils.class);\n\n    /** The wildcard address to listen on all interfaces (either 0.0.0.0 or ::). */\n    private static final String WILDCARD_ADDRESS =\n            new InetSocketAddress(0).getAddress().getHostAddress();\n\n    /**\n     * Turn a fully qualified domain name (fqdn) into a hostname. If the fqdn has multiple subparts\n     * (separated by a period '.'), it will take the first part. Otherwise it takes the entire fqdn.\n     *\n     * @param fqdn The fully qualified domain name.\n     * @return The hostname.\n     */\n    public static String getHostnameFromFQDN(String fqdn) {\n        if (fqdn == null) {\n            throw new IllegalArgumentException(\"fqdn is null\");\n        }\n        int dotPos = fqdn.indexOf('.');\n        if (dotPos == -1) {\n            return fqdn;\n        } else {\n            return fqdn.substring(0, dotPos);\n        }\n    }\n\n    /**\n     * Converts a string of the form \"host:port\" into an {@link URL}.\n     *\n     * @param hostPort The \"host:port\" string.\n     * @return The converted URL.\n     */\n    public static URL getCorrectHostnamePort(String hostPort) {\n        return validateHostPortString(hostPort);\n    }","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/NetUtils.java#L46-L82","documentation":"NetUtils.getHostnameFromFQDN extracts the first label of a fully qualified domain name ('host.example.com' -> 'host'). It performs a null check on the input and throws IllegalArgumentException('fqdn is null') for a null argument, since it cannot derive a hostname from nothing.","triggerScenarios":"Calling NetUtils.getHostnameFromFQDN(null) — i.e. the fqdn string was never resolved (a config option unset, an InetAddress lookup returned null, or a nullable field passed through).","commonSituations":"Hostname configuration (e.g. jobmanager.rpc.address or similar) read as null because the property is absent; code that assumes InetAddress.getHostName() never returns null; refactors that made the fqdn source optional but kept the call unconditional.","solutions":["Ensure the fqdn value is populated before the call — check the config source or lookup that produced it.","Add a null/empty check on the caller side with a meaningful error naming the missing setting.","Default to InetAddress.getLocalHost().getCanonicalHostName() when no explicit fqdn is configured.","Write a unit test passing null to lock in the expected failure mode."],"exampleFix":"// before\nString host = NetUtils.getHostnameFromFQDN(configHostname); // configHostname == null -> IAE\n\n// after\nPreconditions.checkNotNull(configHostname, \"hostname not configured (set 'jobmanager.rpc.address')\");\nString host = NetUtils.getHostnameFromFQDN(configHostname);","handlingStrategy":"validation","validationCode":"if (fqdn == null || fqdn.isBlank()) {\n    throw new IllegalArgumentException(\"fqdn must be set (check hostname config)\");\n}\nString host = NetUtils.getHostnameFromFQDN(fqdn);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["CheckNotNull hostname configs before network helper calls","Default to InetAddress.getLocalHost().getCanonicalHostName() when unset","Test hostname resolution paths with null inputs"],"tags":["network","hostname","null-check","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}