grpc/grpc-java · error · UnsupportedOperationException
Unsupported operation getLocalAddress()
Error message
Unsupported operation getLocalAddress()
What it means
UdsSocket emulates java.net.Socket over an Android LocalSocket. A Unix Domain Socket has no IP local address, so getLocalAddress() intentionally throws UnsupportedOperationException. UdsSocket instead exposes getLocalSocketAddress() returning an opaque, typeless SocketAddress placeholder.
Source
Thrown at android/src/main/java/io/grpc/android/UdsSocket.java:118
@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()");
}
@Override
public InetAddress getLocalAddress() {
throw new UnsupportedOperationException("Unsupported operation getLocalAddress()");
}
@Override
public int getLocalPort() {
throw new UnsupportedOperationException("Unsupported operation getLocalPort()");
}
@Override
public SocketAddress getLocalSocketAddress() {
return new SocketAddress() {};
}
@Override
public boolean getOOBInline() {
throw new UnsupportedOperationException("Unsupported operation getOOBInline()");
}
@OverrideView on GitHub (pinned to 64daddc1f3)
Solutions
- Skip IP-local-address capture for UDS sockets; identify the endpoint by the UDS path instead.
- Guard with a UdsSocket check or catch UnsupportedOperationException in shared socket-inspection code.
- Use getLocalSocketAddress()'s placeholder only for existence checks, never for address data.
Example fix
// before
InetAddress local = socket.getLocalAddress();
// after
InetAddress local = socket.getClass().getSimpleName().equals("UdsSocket")
? null
: socket.getLocalAddress(); 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 local = socket.getLocalAddress();
} catch (UnsupportedOperationException e) {
// UDS: no IP local address; use the configured UDS path
} Prevention
- Never record local/remote IP addresses unconditionally; make them nullable for UDS.
- Use the UDS path as the connection identifier in logs and audits.
- Wrap shared socket-inspection code with a UdsSocket check.
When it happens
Trigger: Calling getLocalAddress() on the UdsSocket created by UdsSocketFactory — e.g. bind/audit logging, connection-tracking code, or libraries that record both local and remote InetAddress for every socket.
Common situations: Network telemetry frameworks assuming IP sockets; security/audit code capturing local bind addresses; tests verifying socket state.
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
- getInetAddress() not supported
- 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/5d06710171f0333a.
Report an issue: GitHub.