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

grpc / grpc-java / #20174

18 Feb 2026 07:57PM UTC coverage: 88.706% (-0.009%) from 88.715%
#20174

push

github

jdcormie
netty: Add RFC 3986 support to the 'unix:' name resolver.

35407 of 39915 relevant lines covered (88.71%)

0.89 hits per line

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

87.5
/../netty/src/main/java/io/grpc/netty/UdsNameResolverProvider.java
1
/*
2
 * Copyright 2022 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.netty;
18

19
import com.google.common.base.Preconditions;
20
import io.grpc.Internal;
21
import io.grpc.NameResolver;
22
import io.grpc.NameResolverProvider;
23
import io.grpc.Uri;
24
import io.netty.channel.unix.DomainSocketAddress;
25
import java.net.SocketAddress;
26
import java.net.URI;
27
import java.util.Collection;
28
import java.util.Collections;
29

30
@Internal
31
public final class UdsNameResolverProvider extends NameResolverProvider {
1✔
32

33
  private static final String SCHEME = "unix";
34

35
  @Override
36
  public NameResolver newNameResolver(Uri targetUri, NameResolver.Args args) {
37
    if (SCHEME.equals(targetUri.getScheme())) {
1✔
38
      return new UdsNameResolver(targetUri.getAuthority(), targetUri.getPath(), args);
1✔
39
    } else {
40
      return null;
×
41
    }
42
  }
43

44
  @Override
45
  public UdsNameResolver newNameResolver(URI targetUri, NameResolver.Args args) {
46
    if (SCHEME.equals(targetUri.getScheme())) {
1✔
47
      // TODO(jdcormie): java.net.URI has a bug where getAuthority() returns null for both the
48
      // undefined and zero-length authority. Doesn't matter for now because UdsNameResolver doesn't
49
      // distinguish these cases.
50
      return new UdsNameResolver(targetUri.getAuthority(), getTargetPathFromUri(targetUri), args);
1✔
51
    } else {
52
      return null;
×
53
    }
54
  }
55

56
  static String getTargetPathFromUri(URI targetUri) {
57
    Preconditions.checkArgument(SCHEME.equals(targetUri.getScheme()), "scheme must be " + SCHEME);
1✔
58
    String targetPath = targetUri.getPath();
1✔
59
    if (targetPath == null) {
1✔
60
      // TODO(jdcormie): This incorrectly includes '?' and any characters that follow. In the
61
      // hierarchical case ('unix:///path'), java.net.URI parses these into a query component that's
62
      // distinct from the path. But in the present "opaque" case ('unix:/path'), what may look like
63
      // a query is considered part of the SSP.
64
      targetPath = Preconditions.checkNotNull(targetUri.getSchemeSpecificPart(), "targetPath");
1✔
65
    }
66
    return targetPath;
1✔
67
  }
68

69
  @Override
70
  public String getDefaultScheme() {
71
    return SCHEME;
1✔
72
  }
73

74
  @Override
75
  protected boolean isAvailable() {
76
    return true;
1✔
77
  }
78

79
  @Override
80
  protected int priority() {
81
    return 3;
1✔
82
  }
83

84
  @Override
85
  public Collection<Class<? extends SocketAddress>> getProducedSocketAddressTypes() {
86
    return Collections.singleton(DomainSocketAddress.class);
1✔
87
  }
88
}
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