grpc/grpc-java · error · UnsupportedOperationException
getInetAddress() not supported
Error message
getInetAddress() not supported
What it means
UdsSocket emulates java.net.Socket over an Android LocalSocket. A LocalSocket has no java.net.InetAddress — it is addressed by a filesystem path or abstract namespace, not an IP address — so getInetAddress() is implemented to throw UnsupportedOperationException instead of returning a meaningless value.
Source
Thrown at android/src/main/java/io/grpc/android/UdsSocket.java:98
@Override
public void connect(SocketAddress endpoint) throws IOException {
localSocket.connect(localSocketAddress);
}
@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
localSocket.connect(localSocketAddress, timeout);
}
@Override
public SocketChannel getChannel() {
throw new UnsupportedOperationException("getChannel() not supported");
}
@Override
public InetAddress getInetAddress() {
throw new UnsupportedOperationException("getInetAddress() not supported");
}
@Override
public InputStream getInputStream() throws IOException {
return new FilterInputStream(localSocket.getInputStream()) {
@Override
public void close() throws IOException {
UdsSocket.this.close();
}
};
}
@Override
public boolean getKeepAlive() {
throw new UnsupportedOperationException("Unsupported operation getKeepAlive()");
}
@OverrideView on GitHub (pinned to 64daddc1f3)
Solutions
- Do not query IP-level metadata on UDS sockets; use the UDS path passed to UdsChannelBuilder.forPath() as the identity instead.
- Guard address-dependent code with a check for UdsSocket (or catch UnsupportedOperationException) and fall back to the configured path.
- If IP-level addressing is required, use a TCP channel rather than the UDS transport.
Example fix
// before
InetAddress addr = socket.getInetAddress();
// after
String peer = "uds:" + udsPath; // identity for UDS sockets
InetAddress addr = socket.getClass().getSimpleName().equals("UdsSocket") ? null : socket.getInetAddress(); Defensive patterns
Strategy: type-guard
Type guard
static boolean isUdsSocket(Socket s) {
return s.getClass().getName().equals("io.grpc.android.UdsSocket");
} Try / catch
try {
InetAddress addr = socket.getInetAddress();
} catch (UnsupportedOperationException e) {
String peerId = "uds:" + configuredPath; // use the UDS path as identity
} Prevention
- Identify UDS connections by their filesystem/abstract path, not InetAddress.
- Make telemetry code null-tolerant for address fields when the transport is UDS.
- Catch UnsupportedOperationException in any generic socket-metadata collector.
When it happens
Trigger: Calling getInetAddress() on the UdsSocket produced by UdsSocketFactory, e.g. logging code, security checks, or libraries that record the remote IP of a connected socket.
Common situations: Network monitoring/logging frameworks capturing peer addresses; retry or policy logic keyed on the remote IP; tests asserting socket metadata.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- getChannel() not supported
- Unsupported operation getLocalAddress()
- Unsupported operation getLocalPort()
- Unsupported operation getKeepAlive()
- Unsupported operation getOOBInline()
AI-assisted analysis of grpc/grpc-java@64daddc1f3 (2026-09-08).
Data as JSON: /api/errors/342b25447bc518dd.
Report an issue: GitHub.