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

grpc / grpc-java / #20320

17 Jun 2026 05:11PM UTC coverage: 88.886% (+0.01%) from 88.874%
#20320

push

github

web-flow
api: Add Grpc.newChannelBuilder accepting NameResolverRegistry (#11901)

This introduces a new `Grpc.newChannelBuilder` overload that allows callers to pass an explicit `NameResolverRegistry`. Fixes #11055

36550 of 41120 relevant lines covered (88.89%)

0.89 hits per line

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

88.24
/../okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelProvider.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.okhttp;
18

19
import io.grpc.ChannelCredentials;
20
import io.grpc.Internal;
21
import io.grpc.InternalServiceProviders;
22
import io.grpc.ManagedChannelProvider;
23
import io.grpc.NameResolverProvider;
24
import io.grpc.NameResolverRegistry;
25
import java.net.SocketAddress;
26
import java.util.Collection;
27

28
/**
29
 * Provider for {@link OkHttpChannelBuilder} instances.
30
 */
31
@Internal
32
public final class OkHttpChannelProvider extends ManagedChannelProvider {
1✔
33

34
  @Override
35
  public boolean isAvailable() {
36
    return true;
1✔
37
  }
38

39
  @Override
40
  public int priority() {
41
    return InternalServiceProviders.isAndroid(getClass().getClassLoader()) ? 8 : 3;
1✔
42
  }
43

44
  @Override
45
  public OkHttpChannelBuilder builderForAddress(String name, int port) {
46
    return OkHttpChannelBuilder.forAddress(name, port);
1✔
47
  }
48

49
  @Override
50
  public OkHttpChannelBuilder builderForTarget(String target) {
51
    return OkHttpChannelBuilder.forTarget(target);
1✔
52
  }
53

54
  @Override
55
  public NewChannelBuilderResult newChannelBuilder(String target, ChannelCredentials creds) {
56
    OkHttpChannelBuilder.SslSocketFactoryResult result =
1✔
57
        OkHttpChannelBuilder.sslSocketFactoryFrom(creds);
1✔
58
    if (result.error != null) {
1✔
59
      return NewChannelBuilderResult.error(result.error);
1✔
60
    }
61
    return NewChannelBuilderResult.channelBuilder(new OkHttpChannelBuilder(
1✔
62
        target, creds, result.callCredentials, result.factory));
63
  }
64

65
  @Override
66
  public NewChannelBuilderResult newChannelBuilder(String target, ChannelCredentials creds,
67
                                                   NameResolverRegistry nameResolverRegistry,
68
                                                   NameResolverProvider nameResolverProvider) {
69
    OkHttpChannelBuilder.SslSocketFactoryResult result =
1✔
70
        OkHttpChannelBuilder.sslSocketFactoryFrom(creds);
1✔
71
    if (result.error != null) {
1✔
72
      return NewChannelBuilderResult.error(result.error);
×
73
    }
74
    OkHttpChannelBuilder builder = new OkHttpChannelBuilder(
1✔
75
        target, creds, result.callCredentials, result.factory,
76
        nameResolverRegistry, nameResolverProvider);
77
    return NewChannelBuilderResult.channelBuilder(builder);
1✔
78
  }
79

80
  @Override
81
  protected Collection<Class<? extends SocketAddress>> getSupportedSocketAddressTypes() {
82
    return OkHttpChannelBuilder.getSupportedSocketAddressTypes();
×
83
  }
84
}
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