grpc/grpc-java · info · UnsupportedOperationException
Unsupported operation setTrafficClass()
Error message
Unsupported operation setTrafficClass()
What it means
setTrafficClass() writes the IP_TOS/DSCP marking for IP packets, which is inapplicable to Unix domain sockets where no IP header exists. UdsSocket throws UnsupportedOperationException to make this explicit.
Solutions
- Do not set traffic class on UDS sockets — packets never traverse an IP network
- Apply QoS marking only on TCP/UDP channels; keep it out of UDS channel setup
- Handle or skip UnsupportedOperationException when applying option sets generically
Example fix
// before
socket.setTrafficClass(0x10); // IPTOS_LOWCOST
// after
if (!(socket instanceof io.grpc.android.UdsSocket)) {
socket.setTrafficClass(0x10);
} Defensive patterns
Strategy: validation
Validate before calling
boolean canMarkTraffic = !(socket instanceof io.grpc.android.UdsSocket);
Type guard
static boolean supportsTrafficClass(java.net.Socket s) { return !(s instanceof io.grpc.android.UdsSocket); } Try / catch
try { socket.setTrafficClass(tc); } catch (UnsupportedOperationException e) { /* no IP header on UDS */ } Prevention
- Restrict QoS/DSCP marking code to TCP/UDP transports
- Audit shared network-policy modules when adding 'uds:' gRPC targets
When it happens
Trigger: Calling UdsSocket.setTrafficClass(int) directly, or QoS/network-policy code that marks traffic (IPTOS_LOWCOST/THROUGHPUT/RELIABILITY) on every socket.
Common situations: Enterprise Android apps applying DSCP markings for network policy to all channels; copy-pasted TCP channel configuration used with '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 getTrafficClass()
- 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/e49cf8f9104508f5.
Report an issue: GitHub.
Appendix: source
Thrown at android/src/main/java/io/grpc/android/UdsSocket.java:292
}
@Override
public void setSoTimeout(int timeout) throws SocketException {
try {
localSocket.setSoTimeout(timeout);
} catch (IOException e) {
throw toSocketException(e);
}
}
@Override
public void setTcpNoDelay(boolean on) {
// no-op
}
@Override
public void setTrafficClass(int tc) {
throw new UnsupportedOperationException("Unsupported operation setTrafficClass()");
}
@Override
public synchronized void shutdownInput() throws IOException {
localSocket.shutdownInput();
inputShutdown = true;
}
@Override
public synchronized void shutdownOutput() throws IOException {
localSocket.shutdownOutput();
outputShutdown = true;
}
private static SocketException toSocketException(Throwable e) {
SocketException se = new SocketException();
se.initCause(e);
return se;View on GitHub (pinned to 64daddc1f3)