grpc/grpc-java · info · UnsupportedOperationException
Unsupported operation getTrafficClass()
Error message
Unsupported operation getTrafficClass()
What it means
getTrafficClass() reads the IP_TOS/DSCP traffic-class option, which only applies to IP sockets. UdsSocket delegates to a LocalSocket over a Unix domain socket where this option does not exist, so the override throws UnsupportedOperationException.
Solutions
- Remove traffic-class reads for UDS channels — traffic class is meaningless without IP
- Skip this option in generic socket-option readers when the socket is a UdsSocket
- If QoS per-traffic-class is required, route that traffic over a TCP channel instead
Example fix
// before
int tc = socket.getTrafficClass();
// after
if (!(socket instanceof io.grpc.android.UdsSocket)) {
int tc = socket.getTrafficClass();
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean supportsTrafficClass = !(socket instanceof io.grpc.android.UdsSocket);
Type guard
static boolean isIpSocket(java.net.Socket s) { return !(s instanceof io.grpc.android.UdsSocket); } Try / catch
try { tc = socket.getTrafficClass(); } catch (UnsupportedOperationException e) { tc = 0; } Prevention
- Keep QoS/DSCP logic out of UDS channel code paths
- Gate traffic-class reads on the socket actually using IP transport
When it happens
Trigger: Direct call to UdsSocket.getTrafficClass(), or code that enumerates/reads all Socket options (QoS configuration, network-telemetry harnesses) on the UDS socket.
Common situations: Applying QoS/DSCP settings meant for IP networks to a UDS-based gRPC channel; generic socket-metrics tooling in an Android app using 'uds:' targets.
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
- Unsupported operation setTrafficClass()
- getChannel() not supported
- getInetAddress() not supported
- OkHttpChannelBuilder not found on the classpath
- Unsupported operation getKeepAlive()
AI-assisted analysis of grpc/grpc-java@64daddc1f3 (2026-09-08).
Data as JSON: /api/errors/26e58219db1f5972.
Report an issue: GitHub.
Appendix: source
Thrown at android/src/main/java/io/grpc/android/UdsSocket.java:200
}
@Override
public int getSoTimeout() throws SocketException {
try {
return localSocket.getSoTimeout();
} catch (IOException e) {
throw toSocketException(e);
}
}
@Override
public boolean getTcpNoDelay() {
return true;
}
@Override
public int getTrafficClass() {
throw new UnsupportedOperationException("Unsupported operation getTrafficClass()");
}
@Override
public boolean isBound() {
return localSocket.isBound();
}
@Override
public synchronized boolean isClosed() {
return closed;
}
@Override
public boolean isConnected() {
return localSocket.isConnected();
}
@OverrideView on GitHub (pinned to 64daddc1f3)