apache/hadoop · error · IllegalArgumentException

Unsupported Address type

Error message

Unsupported Address type

What it means

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).

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java:281

   * Puts an integer into the buffer as 4 bytes, big-endian.
   * @param i i.
   */
  protected void xdr_int(int i) {
    buffer[offset++] = (byte) ((i >> 24) & 0xff);
    buffer[offset++] = (byte) ((i >> 16) & 0xff);
    buffer[offset++] = (byte) ((i >> 8) & 0xff);
    buffer[offset++] = (byte) (i & 0xff);
  }

  /**
   * Sends Ganglia Metrics to the configured hosts
   * @throws IOException raised on errors performing I/O.
   */
  protected void emitToGangliaHosts() throws IOException {
    try {
      for (SocketAddress socketAddress : metricsServers) {
        if (socketAddress == null || !(socketAddress instanceof InetSocketAddress))
          throw new IllegalArgumentException("Unsupported Address type");
        InetSocketAddress inetAddress = (InetSocketAddress)socketAddress;
        if(inetAddress.isUnresolved()) {
          throw new UnknownHostException("Unresolved host: " + inetAddress);
        }
        DatagramPacket packet =
          new DatagramPacket(buffer, offset, socketAddress);
        datagramSocket.send(packet);
      }
    } finally {
      // reset the buffer for the next metric to be built
      offset = 0;
    }
  }

  /**
   * Reset the buffer for the next metric to be built
   */
  void resetBuffer() {

View on GitHub (pinned to 2add963021)

Solutions

  1. Verify every entry in the metrics2 '<prefix>.servers' property is a plain 'host:port' pair, comma/semicolon separated
  2. If you subclass AbstractGangliaSink, make sure your server-parsing code only adds InetSocketAddress instances (use new InetSocketAddress(host, port))
  3. Add a filter in emitToGangliaHosts (or before putMetrics) that skips or logs entries that are not InetSocketAddress before the throw is reached

Example fix

// before
metricsServers.add(new UnixDomainSocketAddress("/tmp/gmond.sock"));
// later: emitToGangliaHosts() throws IllegalArgumentException("Unsupported Address type")

// after
metricsServers.add(new InetSocketAddress("ganglia.example.com", 8649));
Defensive patterns

Strategy: type-guard

Validate before calling

boolean allInet = metricsServers.stream()
    .allMatch(a -> a instanceof InetSocketAddress);
if (!allInet) throw new IllegalStateException("metricsServers contains a non-InetSocketAddress entry");

Type guard

static boolean isEmittableAddress(SocketAddress a) {
  return a instanceof InetSocketAddress;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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