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

grpc / grpc-java / #18883

03 Nov 2023 04:57PM UTC coverage: 88.246% (+0.03%) from 88.218%
#18883

push

github

web-flow
core, netty, okhttp: implement new logic for nameResolverFactory API in channelBuilder (#10590)

* core, netty, okhttp: implement new logic for nameResolverFactory API in channelBuilder
fix ManagedChannelImpl to use NameResolverRegistry instead of NameResolverFactory
fix the ManagedChannelImplBuilder and remove nameResolverFactory

* Integrate target parsing and NameResolverProvider searching

Actually creating the name resolver is now delayed to the end of
ManagedChannelImpl.getNameResolver; we don't want to call into the name
resolver to determine if we should use the name resolver.

Added getDefaultScheme() to NameResolverRegistry to avoid needing
NameResolver.Factory.
---------

Co-authored-by: Eric Anderson <ejona@google.com>

30370 of 34415 relevant lines covered (88.25%)

0.88 hits per line

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

90.91
/../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 java.net.SocketAddress;
24
import java.util.Collection;
25

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

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

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

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

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

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

63
  @Override
64
  protected Collection<Class<? extends SocketAddress>> getSupportedSocketAddressTypes() {
65
    return OkHttpChannelBuilder.getSupportedSocketAddressTypes();
×
66
  }
67
}
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