{"record":{"id":"629548a0856ebe8e","repo":"grpc/grpc-java","slug":"call-forname-instead","errorCode":null,"errorMessage":"call forName() instead","messagePattern":"call forName\\(\\) instead","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"inprocess/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java","lineNumber":91,"sourceCode":"    return new InProcessChannelBuilder(null, checkNotNull(target, \"target\"));\n  }\n\n  /**\n   * Create a channel builder that will connect to the server referenced by the given address.\n   *\n   * @param address the address of the server to connect to\n   * @return a new builder\n   */\n  public static InProcessChannelBuilder forAddress(SocketAddress address) {\n    return new InProcessChannelBuilder(checkNotNull(address, \"address\"), null);\n  }\n\n  /**\n   * Always fails.  Call {@link #forName} instead.\n   */\n  @DoNotCall(\"Unsupported. Use forName() instead\")\n  public static InProcessChannelBuilder forAddress(String name, int port) {\n    throw new UnsupportedOperationException(\"call forName() instead\");\n  }\n\n  private final ManagedChannelImplBuilder managedChannelImplBuilder;\n  private ScheduledExecutorService scheduledExecutorService;\n  private int maxInboundMetadataSize = Integer.MAX_VALUE;\n  private boolean transportIncludeStatusCause = false;\n  private long assumedMessageSize = -1;\n\n  private InProcessChannelBuilder(@Nullable SocketAddress directAddress, @Nullable String target) {\n\n    final class InProcessChannelTransportFactoryBuilder implements ClientTransportFactoryBuilder {\n      @Override\n      public ClientTransportFactory buildClientTransportFactory() {\n        return buildTransportFactory();\n      }\n    }\n\n    if (directAddress != null) {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/inprocess/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java#L73-L109","documentation":"InProcessChannelBuilder.forAddress(String, int) is intentionally unsupported because in-process transport has no network address; channels are identified by name. The two-argument overload always throws UnsupportedOperationException and is marked @DoNotCall.","triggerScenarios":"Calling InProcessChannelBuilder.forAddress(host, port) instead of InProcessChannelBuilder.forName(serverName).","commonSituations":"Reusing generic channel-builder factory code across netty/inprocess transports; converting an app to in-process transport while keeping address-based setup.","solutions":["Use InProcessChannelBuilder.forName(target) where target matches the name given to InProcessServerBuilder.forName(...).","Use InProcessChannelBuilder.forName(InProcessServerBuilder.generateName()) when creating a server without a fixed name.","If an address-based channel is truly needed, use NettyChannelBuilder/OkHttpChannelBuilder instead."],"exampleFix":"// before\nManagedChannel ch = InProcessChannelBuilder.forAddress(\"localhost\", 8080).build();\n// after\nManagedChannel ch = InProcessChannelBuilder.forName(\"my-inprocess-server\").build();","handlingStrategy":"validation","validationCode":"if (useInProcess && target.contains(\":\")) throw new IllegalArgumentException(\"in-process channels must use forName(target), not forAddress(host, port)\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use forName for in-process channels","Match the name used in InProcessServerBuilder.forName","Do not share address-based builder code with in-process transport"],"tags":["grpc","inprocess","unsupported-operation"],"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"}