{"record":{"id":"342b25447bc518dd","repo":"grpc/grpc-java","slug":"getinetaddress-not-supported","errorCode":null,"errorMessage":"getInetAddress() not supported","messagePattern":"getInetAddress\\(\\) not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"android/src/main/java/io/grpc/android/UdsSocket.java","lineNumber":98,"sourceCode":"\n  @Override\n  public void connect(SocketAddress endpoint) throws IOException {\n    localSocket.connect(localSocketAddress);\n  }\n\n  @Override\n  public void connect(SocketAddress endpoint, int timeout) throws IOException {\n    localSocket.connect(localSocketAddress, timeout);\n  }\n\n  @Override\n  public SocketChannel getChannel() {\n    throw new UnsupportedOperationException(\"getChannel() not supported\");\n  }\n\n  @Override\n  public InetAddress getInetAddress() {\n    throw new UnsupportedOperationException(\"getInetAddress() not supported\");\n  }\n\n  @Override\n  public InputStream getInputStream() throws IOException {\n    return new FilterInputStream(localSocket.getInputStream()) {\n      @Override\n      public void close() throws IOException {\n        UdsSocket.this.close();\n      }\n    };\n  }\n\n  @Override\n  public boolean getKeepAlive() {\n    throw new UnsupportedOperationException(\"Unsupported operation getKeepAlive()\");\n  }\n\n  @Override","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/android/src/main/java/io/grpc/android/UdsSocket.java#L80-L116","documentation":"UdsSocket emulates java.net.Socket over an Android LocalSocket. A LocalSocket has no java.net.InetAddress — it is addressed by a filesystem path or abstract namespace, not an IP address — so getInetAddress() is implemented to throw UnsupportedOperationException instead of returning a meaningless value.","triggerScenarios":"Calling getInetAddress() on the UdsSocket produced by UdsSocketFactory, e.g. logging code, security checks, or libraries that record the remote IP of a connected socket.","commonSituations":"Network monitoring/logging frameworks capturing peer addresses; retry or policy logic keyed on the remote IP; tests asserting socket metadata.","solutions":["Do not query IP-level metadata on UDS sockets; use the UDS path passed to UdsChannelBuilder.forPath() as the identity instead.","Guard address-dependent code with a check for UdsSocket (or catch UnsupportedOperationException) and fall back to the configured path.","If IP-level addressing is required, use a TCP channel rather than the UDS transport."],"exampleFix":"// before\nInetAddress addr = socket.getInetAddress();\n// after\nString peer = \"uds:\" + udsPath; // identity for UDS sockets\nInetAddress addr = socket.getClass().getSimpleName().equals(\"UdsSocket\") ? null : socket.getInetAddress();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isUdsSocket(Socket s) {\n  return s.getClass().getName().equals(\"io.grpc.android.UdsSocket\");\n}","tryCatchPattern":"try {\n  InetAddress addr = socket.getInetAddress();\n} catch (UnsupportedOperationException e) {\n  String peerId = \"uds:\" + configuredPath; // use the UDS path as identity\n}","preventionTips":["Identify UDS connections by their filesystem/abstract path, not InetAddress.","Make telemetry code null-tolerant for address fields when the transport is UDS.","Catch UnsupportedOperationException in any generic socket-metadata collector."],"tags":["grpc","android","unix-domain-socket","socket","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}