{"record":{"id":"db3096f2a026129d","repo":"apache/hadoop","slug":"unsupported-address-type","errorCode":null,"errorMessage":"Unsupported Address type","messagePattern":"Unsupported Address type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java","lineNumber":281,"sourceCode":"   * Puts an integer into the buffer as 4 bytes, big-endian.\n   * @param i i.\n   */\n  protected void xdr_int(int i) {\n    buffer[offset++] = (byte) ((i >> 24) & 0xff);\n    buffer[offset++] = (byte) ((i >> 16) & 0xff);\n    buffer[offset++] = (byte) ((i >> 8) & 0xff);\n    buffer[offset++] = (byte) (i & 0xff);\n  }\n\n  /**\n   * Sends Ganglia Metrics to the configured hosts\n   * @throws IOException raised on errors performing I/O.\n   */\n  protected void emitToGangliaHosts() throws IOException {\n    try {\n      for (SocketAddress socketAddress : metricsServers) {\n        if (socketAddress == null || !(socketAddress instanceof InetSocketAddress))\n          throw new IllegalArgumentException(\"Unsupported Address type\");\n        InetSocketAddress inetAddress = (InetSocketAddress)socketAddress;\n        if(inetAddress.isUnresolved()) {\n          throw new UnknownHostException(\"Unresolved host: \" + inetAddress);\n        }\n        DatagramPacket packet =\n          new DatagramPacket(buffer, offset, socketAddress);\n        datagramSocket.send(packet);\n      }\n    } finally {\n      // reset the buffer for the next metric to be built\n      offset = 0;\n    }\n  }\n\n  /**\n   * Reset the buffer for the next metric to be built\n   */\n  void resetBuffer() {","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java#L263-L299","documentation":"Thrown by AbstractGangliaSink.emitToGangliaHosts() when an entry in the configured Ganglia server list (metricsServers) is null or is not a java.net.InetSocketAddress. The sink iterates metricsServers (built from the metrics2 '*.servers' property) and requires every entry to be an InetSocketAddress before constructing a DatagramPacket. It is a defensive guard: the stock parse() path only ever creates InetSocketAddress values, so hitting it means the list was populated by different code (a subclass or test).","triggerScenarios":"Calling putMetrics() on GangliaSink30/GangliaSink31 after metricsServers was populated with a custom SocketAddress subclass (e.g., a mock address injected by a unit test), or a subclass of AbstractGangliaSink overriding the server-parsing logic and inserting null or non-InetSocketAddress entries into metricsServers.","commonSituations":"Custom Ganglia sink subclasses that build metricsServers differently from the base class; unit tests injecting fake addresses; a corrupted/edited servers property that produces an empty token that parses to a null entry.","solutions":["Verify every entry in the metrics2 '<prefix>.servers' property is a plain 'host:port' pair, comma/semicolon separated","If you subclass AbstractGangliaSink, make sure your server-parsing code only adds InetSocketAddress instances (use new InetSocketAddress(host, port))","Add a filter in emitToGangliaHosts (or before putMetrics) that skips or logs entries that are not InetSocketAddress before the throw is reached"],"exampleFix":"// before\nmetricsServers.add(new UnixDomainSocketAddress(\"/tmp/gmond.sock\"));\n// later: emitToGangliaHosts() throws IllegalArgumentException(\"Unsupported Address type\")\n\n// after\nmetricsServers.add(new InetSocketAddress(\"ganglia.example.com\", 8649));","handlingStrategy":"type-guard","validationCode":"boolean allInet = metricsServers.stream()\n    .allMatch(a -> a instanceof InetSocketAddress);\nif (!allInet) throw new IllegalStateException(\"metricsServers contains a non-InetSocketAddress entry\");","typeGuard":"static boolean isEmittableAddress(SocketAddress a) {\n  return a instanceof InetSocketAddress;\n}","tryCatchPattern":null,"preventionTips":["Keep metrics2 '*.servers' entries in plain 'host:port' form","In AbstractGangliaSink subclasses, only ever add new InetSocketAddress(host, port) to metricsServers","In tests, inject InetSocketAddress instances rather than mock SocketAddress types"],"tags":["ganglia","metrics2","socket-address","configuration","hadoop-common"],"backgroundTag":"invalid-configuration-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}