{"record":{"id":"f6a9a7052087131b","repo":"grpc/grpc-java","slug":"unsupported-operation-getreuseaddress","errorCode":null,"errorMessage":"Unsupported operation getReuseAddress()","messagePattern":"Unsupported operation getReuseAddress\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"info","filePath":"android/src/main/java/io/grpc/android/UdsSocket.java","lineNumber":167,"sourceCode":"  }\n\n  @Override\n  public int getReceiveBufferSize() throws SocketException {\n    try {\n      return localSocket.getReceiveBufferSize();\n    } catch (IOException e) {\n      throw toSocketException(e);\n    }\n  }\n\n  @Override\n  public SocketAddress getRemoteSocketAddress() {\n    return new SocketAddress() {};\n  }\n\n  @Override\n  public boolean getReuseAddress() {\n    throw new UnsupportedOperationException(\"Unsupported operation getReuseAddress()\");\n  }\n\n  @Override\n  public int getSendBufferSize() throws SocketException {\n    try {\n      return localSocket.getSendBufferSize();\n    } catch (IOException e) {\n      throw toSocketException(e);\n    }\n  }\n\n  @Override\n  public int getSoLinger() {\n    return -1; // unsupported\n  }\n\n  @Override\n  public int getSoTimeout() throws SocketException {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/android/src/main/java/io/grpc/android/UdsSocket.java#L149-L185","documentation":"getReuseAddress() reports the SO_REUSEADDR socket option, which is a TCP/IP concept and not supported by the underlying Android LocalSocket used by UdsSocket. The override throws UnsupportedOperationException unconditionally rather than returning a misleading value.","triggerScenarios":"Calling UdsSocket.getReuseAddress() directly, or framework code that reads all standard socket options (e.g. generic socket configuration/inspection utilities) on this socket.","commonSituations":"Applying a shared SocketOption configurator written for TCP sockets to the UDS transport; copying connection-setup code from a TCP gRPC channel into a UDS one.","solutions":["Do not query SO_REUSEADDR on UdsSocket; it does not apply to Unix domain sockets","Make option-reading code skip unsupported options for UDS sockets (catch UnsupportedOperationException or check socket type first)","Use an AndroidChannelBuilder/plain LocalSocket API surface instead of java.net.Socket option accessors"],"exampleFix":"// before\nboolean reuse = socket.getReuseAddress();\n// after\nif (socket instanceof io.grpc.android.UdsSocket) {\n  // SO_REUSEADDR not applicable to UDS\n} else {\n  boolean reuse = socket.getReuseAddress();\n}","handlingStrategy":"try-catch","validationCode":"boolean canReadReuseAddr = !(socket instanceof io.grpc.android.UdsSocket);","typeGuard":"static boolean supportsSocketOptions(java.net.Socket s) { return !(s instanceof io.grpc.android.UdsSocket); }","tryCatchPattern":"try { reuse = socket.getReuseAddress(); } catch (UnsupportedOperationException e) { reuse = false; }","preventionTips":["Never apply TCP-only option readers to Unix-domain sockets","Write one shared socket-option accessor that skips unsupported options per transport","Log skipped options instead of failing during diagnostics"],"tags":["grpc","android","unix-domain-socket","socket-options"],"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"}