{"record":{"id":"26e58219db1f5972","repo":"grpc/grpc-java","slug":"unsupported-operation-gettrafficclass","errorCode":null,"errorMessage":"Unsupported operation getTrafficClass()","messagePattern":"Unsupported operation getTrafficClass\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"info","filePath":"android/src/main/java/io/grpc/android/UdsSocket.java","lineNumber":200,"sourceCode":"  }\n\n  @Override\n  public int getSoTimeout() throws SocketException {\n    try {\n      return localSocket.getSoTimeout();\n    } catch (IOException e) {\n      throw toSocketException(e);\n    }\n  }\n\n  @Override\n  public boolean getTcpNoDelay() {\n    return true;\n  }\n\n  @Override\n  public int getTrafficClass() {\n    throw new UnsupportedOperationException(\"Unsupported operation getTrafficClass()\");\n  }\n\n  @Override\n  public boolean isBound() {\n    return localSocket.isBound();\n  }\n\n  @Override\n  public synchronized boolean isClosed() {\n    return closed;\n  }\n\n  @Override\n  public boolean isConnected() {\n    return localSocket.isConnected();\n  }\n\n  @Override","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/android/src/main/java/io/grpc/android/UdsSocket.java#L182-L218","documentation":"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.","triggerScenarios":"Direct call to UdsSocket.getTrafficClass(), or code that enumerates/reads all Socket options (QoS configuration, network-telemetry harnesses) on the UDS socket.","commonSituations":"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.","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"],"exampleFix":"// before\nint tc = socket.getTrafficClass();\n// after\nif (!(socket instanceof io.grpc.android.UdsSocket)) {\n  int tc = socket.getTrafficClass();\n}","handlingStrategy":"try-catch","validationCode":"boolean supportsTrafficClass = !(socket instanceof io.grpc.android.UdsSocket);","typeGuard":"static boolean isIpSocket(java.net.Socket s) { return !(s instanceof io.grpc.android.UdsSocket); }","tryCatchPattern":"try { tc = socket.getTrafficClass(); } catch (UnsupportedOperationException e) { tc = 0; }","preventionTips":["Keep QoS/DSCP logic out of UDS channel code paths","Gate traffic-class reads on the socket actually using IP transport"],"tags":["grpc","android","unix-domain-socket","qos"],"backgroundTag":"unsupported-operation","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}