aeron-io/aeron · error · IllegalArgumentException
Invalid address length
Error message
Invalid address length: ${address.length} What it means
ResolutionEntryFlyweight.putAddress validates the address byte-array length against the resolution type before writing it into the flyweight. For RES_TYPE_NAME_TO_IP4_MD the address must be exactly ADDRESS_LENGTH_IP4 (4) bytes; any other length throws IllegalArgumentException. This guards against writing malformed addresses into name-to-IP4 resolution entries in the control protocol.
Solutions
- Check address.length == 4 before calling putAddress for IP4 entries.
- Ensure resType() matches the actual address family of the data.
- For IPv6 data, set the entry type to RES_TYPE_NAME_TO_IP6_MD instead.
- Validate the source of the address bytes (e.g. InetAddress.getAddress() length) before encoding.
Example fix
// before flyweight.resType(RES_TYPE_NAME_TO_IP4_MD); flyweight.putAddress(inet6Address.getAddress()); // 16 bytes into IP4 entry // after final byte[] bytes = address.getAddress(); flyweight.resType(bytes.length == 4 ? RES_TYPE_NAME_TO_IP4_MD : RES_TYPE_NAME_TO_IP6_MD); flyweight.putAddress(bytes);
Defensive patterns
Strategy: validation
Validate before calling
if (address != null && address.length == ResolutionEntryFlyweight.ADDRESS_LENGTH_IP4
&& flyweight.resType() == ResolutionEntryFlyweight.RES_TYPE_NAME_TO_IP4_MD)
{
flyweight.putAddress(address);
} Type guard
boolean isIp4AddressBytes(final byte[] address)
{
return address != null && address.length == 4;
} Try / catch
try
{
flyweight.putAddress(address);
}
catch (final IllegalArgumentException ex)
{
LOGGER.error("resolution entry address length mismatch", ex);
} Prevention
- Match resType to the address family before putAddress.
- Use InetAddress.getAddress() so lengths are canonical (4 or 16).
- Never pass hostname strings' bytes as the address payload.
- Add unit tests covering both address families.
When it happens
Trigger: Calling putAddress with an address array whose length is not 4 while resType() is RES_TYPE_NAME_TO_IP4_MD — e.g. passing an IPv6 address, a hostname byte array, or an empty array.
Common situations: Mixing IPv4 and IPv6 addresses when building resolution entries; parsing a name-resolution response and re-encoding with the wrong resType; test fixtures with placeholder addresses.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Insufficient length:
- Invalid fragmentCountLimit=" + fragmentCountLimit
- Invalid catalog capacity provided: expected value >= " +…
- recordingId " + recordingId + " is less than or equal to…
- className is empty
AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12).
Data as JSON: /api/errors/bcab13f1c133d3b6.
Report an issue: GitHub.
Appendix: source
Thrown at aeron-client/src/main/java/io/aeron/protocol/ResolutionEntryFlyweight.java:246
public int ageInMs()
{
return getInt(AGE_IN_MS_FIELD_OFFSET, LITTLE_ENDIAN);
}
/**
* Put the address into the resolution entry. It must come after calling {@link #resType(byte)}.
*
* @param address to be written for the resolution entry.
* @return this for a fluent API.
*/
public ResolutionEntryFlyweight putAddress(final byte[] address)
{
switch (resType())
{
case RES_TYPE_NAME_TO_IP4_MD:
if (ADDRESS_LENGTH_IP4 != address.length)
{
throw new IllegalArgumentException("Invalid address length: " + address.length);
}
putBytes(ADDRESS_FIELD_OFFSET, address, 0, ADDRESS_LENGTH_IP4);
break;
case RES_TYPE_NAME_TO_IP6_MD:
if (ADDRESS_LENGTH_IP6 != address.length)
{
throw new IllegalArgumentException("Invalid address length: " + address.length);
}
putBytes(ADDRESS_FIELD_OFFSET, address, 0, ADDRESS_LENGTH_IP6);
break;
default:
throw new IllegalStateException("unknown RES_TYPE=" + resType());
}
return this;
}View on GitHub (pinned to 6d60124e15)