{"record":{"id":"48e378363941e78e","repo":"grpc/grpc-java","slug":"unsupported-call-use-forport-int-servercredenti","errorCode":null,"errorMessage":"Unsupported call - use forPort(int, ServerCredentials)","messagePattern":"Unsupported call - use forPort\\(int, ServerCredentials\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"xds/src/main/java/io/grpc/xds/XdsServerBuilder.java","lineNumber":133,"sourceCode":"   * <p>This configurator will subsequently be used to configure any child channels\n   * created by that server.\n   *\n   * @param channelConfigurator the configurator to store in the channel.\n   * @return this\n   */\n  public XdsServerBuilder childChannelConfigurator(ChannelConfigurator channelConfigurator) {\n    checkNotNull(channelConfigurator, \"channelConfigurator\");\n    ChannelConfigurator oldConfigurator = this.channelConfigurator;\n    this.channelConfigurator = builder -> {\n      oldConfigurator.configureChannelBuilder(builder);\n      channelConfigurator.configureChannelBuilder(builder);\n    };\n    return this;\n  }\n\n  @DoNotCall(\"Unsupported. Use forPort(int, ServerCredentials) instead\")\n  public static ServerBuilder<?> forPort(int port) {\n    throw new UnsupportedOperationException(\n            \"Unsupported call - use forPort(int, ServerCredentials)\");\n  }\n\n  /** Creates a gRPC server builder for the given port. */\n  public static XdsServerBuilder forPort(int port, ServerCredentials serverCredentials) {\n    checkNotNull(serverCredentials, \"serverCredentials\");\n    InternalProtocolNegotiator.ServerFactory originalNegotiatorFactory =\n            InternalNettyServerCredentials.toNegotiator(serverCredentials);\n    ServerCredentials wrappedCredentials = InternalNettyServerCredentials.create(\n            new FilterChainMatchingNegotiatorServerFactory(originalNegotiatorFactory));\n    NettyServerBuilder nettyDelegate = NettyServerBuilder.forPort(port, wrappedCredentials);\n    return new XdsServerBuilder(nettyDelegate, port);\n  }\n\n  /** Creates a gRPC server builder for the given address. */\n  public static XdsServerBuilder forAddress(\n      SocketAddress address, ServerCredentials serverCredentials) {\n    checkNotNull(address, \"address\");","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/xds/src/main/java/io/grpc/xds/XdsServerBuilder.java#L115-L151","documentation":"XdsServerBuilder.forPort(int) is explicitly annotated @DoNotCall and always throws UnsupportedOperationException. The xDS server requires transport security credentials, so the single-argument forPort overload is intentionally unusable; callers must supply ServerCredentials via forPort(int, ServerCredentials).","triggerScenarios":"Calling XdsServerBuilder.forPort(int port) — the deprecated/unsupported single-argument static factory — instead of the two-argument overload. Every invocation of that method throws immediately.","commonSituations":"Migrating code written against classic gRPC ServerBuilder.forPort(port) (which works without credentials) to XdsServerBuilder; copy-pasted server bootstrap code; following outdated tutorials from before the gRPC credentials API change (1.37+).","solutions":["Replace the call with XdsServerBuilder.forPort(port, serverCredentials), passing credentials such as TlsServerCredentials.create().","If TLS is not desired, explicitly build insecure credentials with InsecureServerCredentials.create() to make the intent clear.","If you truly need a plain server without xDS, use netty's NettyServerBuilder.forPort(port) instead of XdsServerBuilder."],"exampleFix":"// before\nServerBuilder<?> builder = XdsServerBuilder.forPort(8080);\n// after\nServerBuilder<?> builder = XdsServerBuilder.forPort(8080,\n    TlsServerCredentials.create()); // or InsecureServerCredentials.create()","handlingStrategy":"validation","validationCode":"ServerCredentials creds = TlsServerCredentials.create(); // resolve credentials first\nassert creds != null : \"ServerCredentials required by XdsServerBuilder.forPort\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call single-argument forPort on XdsServerBuilder; it is @DoNotCall.","Always construct ServerCredentials before building an xDS server.","Use IDE nullness/DoNotCall linting to catch unsupported overloads at compile/edit time."],"tags":["grpc","xds","unsupported-operation","server-credentials"],"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"}