• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grpc / grpc-java / #20349

07 Jul 2026 10:24AM UTC coverage: 89.111% (-0.01%) from 89.122%
#20349

push

github

web-flow
enable child channel plugins (#12578)

Implements https://github.com/grpc/proposal/pull/529

38030 of 42677 relevant lines covered (89.11%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

9.38
/../api/src/main/java/io/grpc/ManagedChannelBuilder.java
1
/*
2
 * Copyright 2015 The gRPC Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package io.grpc;
18

19
import com.google.common.base.Preconditions;
20
import java.util.List;
21
import java.util.Map;
22
import java.util.concurrent.Executor;
23
import java.util.concurrent.TimeUnit;
24
import javax.annotation.Nullable;
25

26
/**
27
 * A builder for {@link ManagedChannel} instances.
28
 *
29
 * @param <T> The concrete type of this builder.
30
 */
31
public abstract class ManagedChannelBuilder<T extends ManagedChannelBuilder<T>> {
1✔
32
  /**
33
   * Creates a channel with the target's address and port number.
34
   *
35
   * <p>Note that there is an open JDK bug on {@link java.net.URI} class parsing an ipv6 scope ID:
36
   * bugs.openjdk.org/browse/JDK-8199396. This method is exposed to this bug. If you experience an
37
   * issue, a work-around is to convert the scope ID to its numeric form (e.g. by using
38
   * Inet6Address.getScopeId()) before calling this method.
39
   *
40
   * @see #forTarget(String)
41
   * @since 1.0.0
42
   */
43
  public static ManagedChannelBuilder<?> forAddress(String name, int port) {
44
    return ManagedChannelProvider.provider().builderForAddress(name, port);
1✔
45
  }
46

47
  /**
48
   * Creates a channel with a target string, which can be either an RFC 3986 URI, or an authority
49
   * string.
50
   *
51
   * <p>Example URIs:
52
   * <ul>
53
   *   <li>{@code "dns:///foo.googleapis.com:8080"}</li>
54
   *   <li>{@code "dns:///foo.googleapis.com"}</li>
55
   *   <li>{@code "dns:///%5B2001:db8:85a3:8d3:1319:8a2e:370:7348%5D:443"}</li>
56
   *   <li>{@code "dns://8.8.8.8/foo.googleapis.com:8080"}</li>
57
   *   <li>{@code "dns://8.8.8.8/foo.googleapis.com"}</li>
58
   *   <li>{@code "zookeeper://zk.example.com:9900/example_service"}</li>
59
   *   <li>{@code "intent:#Intent;package=com.some.app;action=a;category=c;end;"}</li>
60
   * </ul>
61
   *
62
   * <p>An authority string will be converted to a URI having the scheme of the name resolver with
63
   * the highest priority (e.g. {@code "dns"}), the empty string as the authority, and
64
   * {@code target} as its absolute path. We recommend libraries specify {@code target} as a URI
65
   * instead since they cannot know which NameResolver will be default at runtime.
66
   * Example authority strings:
67
   * <ul>
68
   *   <li>{@code "localhost"}</li>
69
   *   <li>{@code "127.0.0.1"}</li>
70
   *   <li>{@code "localhost:8080"}</li>
71
   *   <li>{@code "foo.googleapis.com:8080"}</li>
72
   *   <li>{@code "127.0.0.1:8080"}</li>
73
   *   <li>{@code "[2001:db8:85a3:8d3:1319:8a2e:370:7348]"}</li>
74
   *   <li>{@code "[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443"}</li>
75
   * </ul>
76
   *
77
   * <p>The URI form of {@code target} is preferred because it is less ambiguous. For example, the
78
   * target string {@code foo:8080} is a valid authority string with host {@code foo} and port
79
   * {@code 8080} but it is also a valid RFC 3986 URI with scheme {@code foo} and path {@code 8080}.
80
   * gRPC prioritizes the URI form, which means {@code foo:8080} will be treated as a URI with
81
   * scheme {@code foo}. Using {@code dns:///foo:8080} avoids this ambiguity.
82
   *
83
   * <p>Note that there is an open JDK bug on {@link java.net.URI} class parsing an ipv6 scope ID:
84
   * bugs.openjdk.org/browse/JDK-8199396. This method is exposed to this bug. If you experience an
85
   * issue, a work-around is to convert the scope ID to its numeric form (e.g. by using
86
   * Inet6Address.getScopeId()) before calling this method.
87
   * 
88
   * @since 1.0.0
89
   */
90
  public static ManagedChannelBuilder<?> forTarget(String target) {
91
    return ManagedChannelProvider.provider().builderForTarget(target);
1✔
92
  }
93

94
  /**
95
   * Execute application code directly in the transport thread.
96
   *
97
   * <p>Depending on the underlying transport, using a direct executor may lead to substantial
98
   * performance improvements. However, it also requires the application to not block under
99
   * any circumstances.
100
   *
101
   * <p>Calling this method is semantically equivalent to calling {@link #executor(Executor)} and
102
   * passing in a direct executor. However, this is the preferred way as it may allow the transport
103
   * to perform special optimizations.
104
   *
105
   * @return this
106
   * @since 1.0.0
107
   */
108
  public abstract T directExecutor();
109

110
  /**
111
   * Provides a custom executor.
112
   *
113
   * <p>It's an optional parameter. If the user has not provided an executor when the channel is
114
   * built, the builder will use a static cached thread pool.
115
   *
116
   * <p>The channel won't take ownership of the given executor. It's caller's responsibility to
117
   * shut down the executor when it's desired.
118
   *
119
   * @return this
120
   * @since 1.0.0
121
   */
122
  public abstract T executor(Executor executor);
123

124
  /**
125
   * Provides a custom executor that will be used for operations that block or are expensive, to
126
   * avoid blocking asynchronous code paths. For example, DNS queries and OAuth token fetching over
127
   * HTTP could use this executor.
128
   *
129
   * <p>It's an optional parameter. If the user has not provided an executor when the channel is
130
   * built, the builder will use a static cached thread pool.
131
   *
132
   * <p>The channel won't take ownership of the given executor. It's caller's responsibility to shut
133
   * down the executor when it's desired.
134
   *
135
   * @return this
136
   * @throws UnsupportedOperationException if unsupported
137
   * @since 1.25.0
138
   */
139
  public T offloadExecutor(Executor executor) {
140
    throw new UnsupportedOperationException();
×
141
  }
142

143
  /**
144
   * Adds interceptors that will be called before the channel performs its real work. This is
145
   * functionally equivalent to using {@link ClientInterceptors#intercept(Channel, List)}, but while
146
   * still having access to the original {@code ManagedChannel}. Interceptors run in the reverse
147
   * order in which they are added, just as with consecutive calls to {@code
148
   * ClientInterceptors.intercept()}.
149
   *
150
   * @return this
151
   * @since 1.0.0
152
   */
153
  public abstract T intercept(List<ClientInterceptor> interceptors);
154

155
  /**
156
   * Adds interceptors that will be called before the channel performs its real work. This is
157
   * functionally equivalent to using {@link ClientInterceptors#intercept(Channel,
158
   * ClientInterceptor...)}, but while still having access to the original {@code ManagedChannel}.
159
   * Interceptors run in the reverse order in which they are added, just as with consecutive calls
160
   * to {@code ClientInterceptors.intercept()}.
161
   *
162
   * @return this
163
   * @since 1.0.0
164
   */
165
  public abstract T intercept(ClientInterceptor... interceptors);
166

167
  /**
168
   * Internal-only: Adds a factory that will construct an interceptor based on the channel's target.
169
   * This can be used to work around nameResolverFactory() changing the target string.
170
   */
171
  @Internal
172
  protected T interceptWithTarget(InterceptorFactory factory) {
173
    throw new UnsupportedOperationException();
×
174
  }
175

176
  /** Internal-only. */
177
  @Internal
178
  protected interface InterceptorFactory {
179
    ClientInterceptor newInterceptor(String target);
180
  }
181

182
  /**
183
   * Adds a {@link ClientTransportFilter}. The order of filters being added is the order they will
184
   * be executed
185
   *
186
   * @return this
187
   * @since 1.60.0
188
   */
189
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/10652")
190
  public T addTransportFilter(ClientTransportFilter filter) {
191
    throw new UnsupportedOperationException();
×
192
  }
193

194
  /**
195
   * Provides a custom {@code User-Agent} for the application.
196
   *
197
   * <p>It's an optional parameter. The library will provide a user agent independent of this
198
   * option. If provided, the given agent will prepend the library's user agent information.
199
   *
200
   * @return this
201
   * @since 1.0.0
202
   */
203
  public abstract T userAgent(String userAgent);
204

205
  /**
206
   * Overrides the authority used with TLS and HTTP virtual hosting. It does not change what host is
207
   * actually connected to. Is commonly in the form {@code host:port}.
208
   *
209
   * <p>If the channel builder overrides authority, any authority override from name resolution
210
   * result (via {@link EquivalentAddressGroup#ATTR_AUTHORITY_OVERRIDE}) will be discarded.
211
   *
212
   * <p>This method is intended for testing, but may safely be used outside of tests as an
213
   * alternative to DNS overrides.
214
   *
215
   * @return this
216
   * @since 1.0.0
217
   */
218
  public abstract T overrideAuthority(String authority);
219

220
  /**
221
   * Use of a plaintext connection to the server. By default a secure connection mechanism
222
   * such as TLS will be used.
223
   *
224
   * <p>Should only be used for testing or for APIs where the use of such API or the data
225
   * exchanged is not sensitive.
226
   *
227
   * <p>This assumes prior knowledge that the target of this channel is using plaintext.  It will
228
   * not perform HTTP/1.1 upgrades.
229
   *
230
   * @return this
231
   * @throws IllegalStateException if ChannelCredentials were provided when constructing the builder
232
   * @throws UnsupportedOperationException if plaintext mode is not supported.
233
   * @since 1.11.0
234
   */
235
  public T usePlaintext() {
236
    throw new UnsupportedOperationException();
×
237
  }
238

239
  /**
240
   * Makes the client use TLS. Note: this is enabled by default.
241
   *
242
   * <p>It is recommended to use the {@link ChannelCredentials} API
243
   * instead of this method.
244
   *
245
   * @return this
246
   * @throws IllegalStateException if ChannelCredentials were provided when constructing the builder
247
   * @throws UnsupportedOperationException if transport security is not supported.
248
   * @since 1.9.0
249
   */
250
  public T useTransportSecurity() {
251
    throw new UnsupportedOperationException();
×
252
  }
253

254
  /**
255
   * Provides a custom {@link NameResolver.Factory} for the channel. If this method is not called,
256
   * the builder will try the providers registered in the default {@link NameResolverRegistry} for
257
   * the given target.
258
   *
259
   * <p>This method should rarely be used, as name resolvers should provide a {@code
260
   * NameResolverProvider} and users rely on service loading to find implementations in the class
261
   * path. That allows application's configuration to easily choose the name resolver via the
262
   * 'target' string passed to {@link ManagedChannelBuilder#forTarget(String)}.
263
   *
264
   * @return this
265
   * @since 1.0.0
266
   * @deprecated Most usages should use a globally-registered {@link NameResolverProvider} instead,
267
   *     with either the SPI mechanism or {@link NameResolverRegistry#register}. Replacements for
268
   *     all use-cases are not necessarily available yet. See
269
   *     <a href="https://github.com/grpc/grpc-java/issues/7133">#7133</a>.
270
   */
271
  @Deprecated
272
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770")
273
  public abstract T nameResolverFactory(NameResolver.Factory resolverFactory);
274

275
  /**
276
   * Sets the default load-balancing policy that will be used if the service config doesn't specify
277
   * one.  If not set, the default will be the "pick_first" policy.
278
   *
279
   * <p>Policy implementations are looked up in the
280
   * {@link LoadBalancerRegistry#getDefaultRegistry default LoadBalancerRegistry}.
281
   *
282
   * <p>This method is implemented by all stock channel builders that are shipped with gRPC, but may
283
   * not be implemented by custom channel builders, in which case this method will throw.
284
   *
285
   * @return this
286
   * @since 1.18.0
287
   */
288
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
289
  public T defaultLoadBalancingPolicy(String policy) {
290
    throw new UnsupportedOperationException();
×
291
  }
292

293
  /**
294
   * Set the decompression registry for use in the channel. This is an advanced API call and
295
   * shouldn't be used unless you are using custom message encoding. The default supported
296
   * decompressors are in {@link DecompressorRegistry#getDefaultInstance}.
297
   *
298
   * @return this
299
   * @since 1.0.0
300
   */
301
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
302
  public abstract T decompressorRegistry(DecompressorRegistry registry);
303

304
  /**
305
   * Set the compression registry for use in the channel.  This is an advanced API call and
306
   * shouldn't be used unless you are using custom message encoding.   The default supported
307
   * compressors are in {@link CompressorRegistry#getDefaultInstance}.
308
   *
309
   * @return this
310
   * @since 1.0.0
311
   */
312
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
313
  public abstract T compressorRegistry(CompressorRegistry registry);
314

315
  /**
316
   * Set the duration without ongoing RPCs before going to idle mode.
317
   *
318
   * <p>In idle mode the channel shuts down all connections, the NameResolver and the
319
   * LoadBalancer. A new RPC would take the channel out of idle mode. A channel starts in idle mode.
320
   * Defaults to 30 minutes.
321
   *
322
   * <p>This is an advisory option. Do not rely on any specific behavior related to this option.
323
   *
324
   * @return this
325
   * @since 1.0.0
326
   */
327
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2022")
328
  public abstract T idleTimeout(long value, TimeUnit unit);
329

330
  /**
331
   * Sets the maximum message size allowed to be received on the channel. If not called,
332
   * defaults to 4 MiB. The default provides protection to clients who haven't considered the
333
   * possibility of receiving large messages while trying to be large enough to not be hit in normal
334
   * usage.
335
   *
336
   * <p>This method is advisory, and implementations may decide to not enforce this.  Currently,
337
   * the only known transport to not enforce this is {@code InProcessTransport}.
338
   *
339
   * @param bytes the maximum number of bytes a single message can be.
340
   * @return this
341
   * @throws IllegalArgumentException if bytes is negative.
342
   * @since 1.1.0
343
   */
344
  public T maxInboundMessageSize(int bytes) {
345
    // intentional noop rather than throw, this method is only advisory.
346
    Preconditions.checkArgument(bytes >= 0, "bytes must be >= 0");
×
347
    return thisT();
×
348
  }
349

350
  /**
351
   * Sets the maximum size of metadata allowed to be received. {@code Integer.MAX_VALUE} disables
352
   * the enforcement. The default is implementation-dependent, but is not generally less than 8 KiB
353
   * and may be unlimited.
354
   *
355
   * <p>This is cumulative size of the metadata. The precise calculation is
356
   * implementation-dependent, but implementations are encouraged to follow the calculation used for
357
   * <a href="http://httpwg.org/specs/rfc7540.html#rfc.section.6.5.2">
358
   * HTTP/2's SETTINGS_MAX_HEADER_LIST_SIZE</a>. It sums the bytes from each entry's key and value,
359
   * plus 32 bytes of overhead per entry.
360
   *
361
   * @param bytes the maximum size of received metadata
362
   * @return this
363
   * @throws IllegalArgumentException if bytes is non-positive
364
   * @since 1.17.0
365
   */
366
  public T maxInboundMetadataSize(int bytes) {
367
    Preconditions.checkArgument(bytes > 0, "maxInboundMetadataSize must be > 0");
×
368
    // intentional noop rather than throw, this method is only advisory.
369
    return thisT();
×
370
  }
371

372
  /**
373
   * Sets the time without read activity before sending a keepalive ping. An unreasonably small
374
   * value might be increased, and {@code Long.MAX_VALUE} nano seconds or an unreasonably large
375
   * value will disable keepalive. Defaults to infinite.
376
   *
377
   * <p>Clients must receive permission from the service owner before enabling this option.
378
   * Keepalives can increase the load on services and are commonly "invisible" making it hard to
379
   * notice when they are causing excessive load. Clients are strongly encouraged to use only as
380
   * small of a value as necessary.
381
   *
382
   * <p>When the channel implementation supports TCP_USER_TIMEOUT, enabling keepalive will also
383
   * enable TCP_USER_TIMEOUT for the connection. This requires <em>all</em> sent packets to receive
384
   * a TCP acknowledgement before the keepalive timeout. The keepalive time is not used for
385
   * TCP_USER_TIMEOUT, except as a signal to enable the feature. grpc-netty supports
386
   * TCP_USER_TIMEOUT on Linux platforms supported by netty-transport-native-epoll.
387
   *
388
   * @throws UnsupportedOperationException if unsupported
389
   * @see <a href="https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md">gRFC A8
390
   *     Client-side Keepalive</a>
391
   * @see <a href="https://github.com/grpc/proposal/blob/master/A18-tcp-user-timeout.md">gRFC A18
392
   *     TCP User Timeout</a>
393
   * @since 1.7.0
394
   */
395
  public T keepAliveTime(long keepAliveTime, TimeUnit timeUnit) {
396
    throw new UnsupportedOperationException();
×
397
  }
398

399
  /**
400
   * Sets the time waiting for read activity after sending a keepalive ping. If the time expires
401
   * without any read activity on the connection, the connection is considered dead. An unreasonably
402
   * small value might be increased. Defaults to 20 seconds.
403
   *
404
   * <p>This value should be at least multiple times the RTT to allow for lost packets.
405
   *
406
   * @throws UnsupportedOperationException if unsupported
407
   * @see <a href="https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md">gRFC A8
408
   *     Client-side Keepalive</a>
409
   * @see <a href="https://github.com/grpc/proposal/blob/master/A18-tcp-user-timeout.md">gRFC A18
410
   *     TCP User Timeout</a>
411
   * @since 1.7.0
412
   */
413
  public T keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit) {
414
    throw new UnsupportedOperationException();
×
415
  }
416

417
  /**
418
   * Sets whether keepalive will be performed when there are no outstanding RPC on a connection.
419
   * Defaults to {@code false}.
420
   *
421
   * <p>Clients must receive permission from the service owner before enabling this option.
422
   * Keepalives on unused connections can easilly accidentally consume a considerable amount of
423
   * bandwidth and CPU. {@link ManagedChannelBuilder#idleTimeout idleTimeout()} should generally be
424
   * used instead of this option.
425
   *
426
   * @throws UnsupportedOperationException if unsupported
427
   * @see #keepAliveTime(long, TimeUnit)
428
   * @see <a href="https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md">gRFC A8
429
   *     Client-side Keepalive</a>
430
   * @since 1.7.0
431
   */
432
  public T keepAliveWithoutCalls(boolean enable) {
433
    throw new UnsupportedOperationException();
×
434
  }
435

436
  /**
437
   * Sets the maximum number of retry attempts that may be configured by the service config. If the
438
   * service config specifies a larger value it will be reduced to this value.  Setting this number
439
   * to zero is not effectively the same as {@code disableRetry()} because the former does not
440
   * disable
441
   * <a
442
   * href="https://github.com/grpc/proposal/blob/master/A6-client-retries.md#transparent-retries">
443
   * transparent retry</a>.
444
   *
445
   * <p>This method may not work as expected for the current release because retry is not fully
446
   * implemented yet.
447
   *
448
   * @return this
449
   * @since 1.11.0
450
   */
451
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
452
  public T maxRetryAttempts(int maxRetryAttempts) {
453
    throw new UnsupportedOperationException();
×
454
  }
455

456
  /**
457
   * Sets the maximum number of hedged attempts that may be configured by the service config. If the
458
   * service config specifies a larger value it will be reduced to this value.
459
   *
460
   * <p>This method may not work as expected for the current release because retry is not fully
461
   * implemented yet.
462
   *
463
   * @return this
464
   * @since 1.11.0
465
   */
466
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
467
  public T maxHedgedAttempts(int maxHedgedAttempts) {
468
    throw new UnsupportedOperationException();
×
469
  }
470

471
  /**
472
   * Sets the retry buffer size in bytes. If the buffer limit is exceeded, no RPC
473
   * could retry at the moment, and in hedging case all hedges but one of the same RPC will cancel.
474
   * The implementation may only estimate the buffer size being used rather than count the
475
   * exact physical memory allocated. The method does not have any effect if retry is disabled by
476
   * the client.
477
   *
478
   * <p>This method may not work as expected for the current release because retry is not fully
479
   * implemented yet.
480
   *
481
   * @return this
482
   * @since 1.10.0
483
   */
484
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
485
  public T retryBufferSize(long bytes) {
486
    throw new UnsupportedOperationException();
×
487
  }
488

489
  /**
490
   * Sets the per RPC buffer limit in bytes used for retry. The RPC is not retriable if its buffer
491
   * limit is exceeded. The implementation may only estimate the buffer size being used rather than
492
   * count the exact physical memory allocated. It does not have any effect if retry is disabled by
493
   * the client.
494
   *
495
   * <p>This method may not work as expected for the current release because retry is not fully
496
   * implemented yet.
497
   *
498
   * @return this
499
   * @since 1.10.0
500
   */
501
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
502
  public T perRpcBufferLimit(long bytes) {
503
    throw new UnsupportedOperationException();
×
504
  }
505

506

507
  /**
508
   * Disables the retry and hedging subsystem provided by the gRPC library. This is designed for the
509
   * case when users have their own retry implementation and want to avoid their own retry taking
510
   * place simultaneously with the gRPC library layer retry.
511
   *
512
   * @return this
513
   * @since 1.11.0
514
   */
515
  public T disableRetry() {
516
    throw new UnsupportedOperationException();
×
517
  }
518

519
  /**
520
   * Enables the retry and hedging subsystem which will use
521
   * <a href="https://github.com/grpc/proposal/blob/master/A6-client-retries.md#integration-with-service-config">
522
   * per-method configuration</a>. If a method is unconfigured, it will be limited to
523
   * transparent retries, which are safe for non-idempotent RPCs. Service config is ideally provided
524
   * by the name resolver, but may also be specified via {@link #defaultServiceConfig}.
525
   *
526
   * @return this
527
   * @since 1.11.0
528
   */
529
  public T enableRetry() {
530
    throw new UnsupportedOperationException();
×
531
  }
532

533
  /**
534
   * Sets the BinaryLog object that this channel should log to. The channel does not take
535
   * ownership of the object, and users are responsible for calling {@link BinaryLog#close()}.
536
   *
537
   * @param binaryLog the object to provide logging.
538
   * @return this
539
   * @since 1.13.0
540
   */
541
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4017")
542
  public T setBinaryLog(BinaryLog binaryLog) {
543
    throw new UnsupportedOperationException();
×
544
  }
545

546
  /**
547
   * Sets the maximum number of channel trace events to keep in the tracer for each channel or
548
   * subchannel. If set to 0, channel tracing is effectively disabled.
549
   *
550
   * @return this
551
   * @since 1.13.0
552
   */
553
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4471")
554
  public T maxTraceEvents(int maxTraceEvents) {
555
    throw new UnsupportedOperationException();
×
556
  }
557

558
  /**
559
   * Sets the proxy detector to be used in addresses name resolution. If <code>null</code> is passed
560
   * the default proxy detector will be used.  For how proxies work in gRPC, please refer to the
561
   * documentation on {@link ProxyDetector}.
562
   *
563
   * @return this
564
   * @since 1.19.0
565
   */
566
  public T proxyDetector(ProxyDetector proxyDetector) {
567
    throw new UnsupportedOperationException();
×
568
  }
569

570
  /**
571
   * Provides a service config to the channel. The channel will use the default service config when
572
   * the name resolver provides no service config or if the channel disables lookup service config
573
   * from name resolver (see {@link #disableServiceConfigLookUp()}). The argument
574
   * {@code serviceConfig} is a nested map representing a Json object in the most natural way:
575
   *
576
   *        <table border="1">
577
   *          <tr>
578
   *            <td>Json entry</td><td>Java Type</td>
579
   *          </tr>
580
   *          <tr>
581
   *            <td>object</td><td>{@link Map}</td>
582
   *          </tr>
583
   *          <tr>
584
   *            <td>array</td><td>{@link List}</td>
585
   *          </tr>
586
   *          <tr>
587
   *            <td>string</td><td>{@link String}</td>
588
   *          </tr>
589
   *          <tr>
590
   *            <td>number</td><td>{@link Double}</td>
591
   *          </tr>
592
   *          <tr>
593
   *            <td>boolean</td><td>{@link Boolean}</td>
594
   *          </tr>
595
   *          <tr>
596
   *            <td>null</td><td>{@code null}</td>
597
   *          </tr>
598
   *        </table>
599
   *
600
   * <p>If null is passed, then there will be no default service config.
601
   *
602
   * <p>Your preferred JSON parser may not produce results in the format expected. For such cases,
603
   * you can convert its output. For example, if your parser produces Integers and other Numbers
604
   * in addition to Double:
605
   *
606
   * <pre>{@code @SuppressWarnings("unchecked")
607
   * private static Object convertNumbers(Object o) {
608
   *   if (o instanceof Map) {
609
   *     ((Map) o).replaceAll((k,v) -> convertNumbers(v));
610
   *   } else if (o instanceof List) {
611
   *     ((List) o).replaceAll(YourClass::convertNumbers);
612
   *   } else if (o instanceof Number && !(o instanceof Double)) {
613
   *     o = ((Number) o).doubleValue();
614
   *   }
615
   *   return o;
616
   * }}</pre>
617
   *
618
   * @return this
619
   * @throws IllegalArgumentException When the given serviceConfig is invalid or the current version
620
   *         of grpc library can not parse it gracefully. The state of the builder is unchanged if
621
   *         an exception is thrown.
622
   * @since 1.20.0
623
   */
624
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5189")
625
  public T defaultServiceConfig(@Nullable Map<String, ?> serviceConfig) {
626
    throw new UnsupportedOperationException();
×
627
  }
628

629
  /**
630
   * Disables service config look-up from the naming system, which is enabled by default.
631
   *
632
   * @return this
633
   * @since 1.20.0
634
   */
635
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5189")
636
  public T disableServiceConfigLookUp() {
637
    throw new UnsupportedOperationException();
×
638
  }
639

640
  /**
641
   * Adds a {@link MetricSink} for channel to use for configuring and recording metrics.
642
   *
643
   * @return this
644
   * @since 1.64.0
645
   */
646
  @Internal
647
  protected T addMetricSink(MetricSink metricSink) {
648
    throw new UnsupportedOperationException();
×
649
  }
650

651
  /**
652
   * Provides a "custom" argument for the {@link NameResolver}, if applicable, replacing any 'value'
653
   * previously provided for 'key'.
654
   *
655
   * <p>NB: If the selected {@link NameResolver} does not understand 'key', or target URI resolution
656
   * isn't needed at all, your custom argument will be silently ignored.
657
   *
658
   * <p>See {@link NameResolver.Args#getArg(NameResolver.Args.Key)} for more.
659
   *
660
   * @param key identifies the argument in a type-safe manner
661
   * @param value the argument itself
662
   * @return this
663
   */
664
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770")
665
  public <X> T setNameResolverArg(NameResolver.Args.Key<X> key, X value) {
666
    throw new UnsupportedOperationException();
×
667
  }
668

669

670
  /**
671
   * Sets a configurator that will be applied to all internal child channels created by this
672
   * channel.
673
   *
674
   * <p>This allows injecting universal configuration (like interceptors)
675
   * into auxiliary channels created by gRPC infrastructure, such as xDS control plane connections.
676
   *
677
   * @param channelConfigurator the configurator to apply.
678
   * @return this
679
   * @since 1.83.0
680
   */
681
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/12574")
682
  public T childChannelConfigurator(ChannelConfigurator channelConfigurator) {
683
    throw new UnsupportedOperationException("Not implemented");
×
684
  }
685

686
  /**
687
   * Builds a channel using the given parameters.
688
   *
689
   * @since 1.0.0
690
   */
691
  public abstract ManagedChannel build();
692

693
  /**
694
   * Returns the correctly typed version of the builder.
695
   */
696
  private T thisT() {
697
    @SuppressWarnings("unchecked")
698
    T thisT = (T) this;
×
699
    return thisT;
×
700
  }
701
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc