• 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

98.03
/../api/src/main/java/io/grpc/Uri.java
1
/*
2
 * Copyright 2025 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 static com.google.common.base.Preconditions.checkArgument;
20
import static com.google.common.base.Preconditions.checkNotNull;
21
import static com.google.common.base.Preconditions.checkState;
22

23
import com.google.common.base.VerifyException;
24
import com.google.common.collect.ImmutableList;
25
import com.google.common.net.InetAddresses;
26
import com.google.errorprone.annotations.CanIgnoreReturnValue;
27
import java.net.InetAddress;
28
import java.net.URISyntaxException;
29
import java.nio.ByteBuffer;
30
import java.nio.CharBuffer;
31
import java.nio.charset.CharacterCodingException;
32
import java.nio.charset.CharsetEncoder;
33
import java.nio.charset.CodingErrorAction;
34
import java.nio.charset.MalformedInputException;
35
import java.nio.charset.StandardCharsets;
36
import java.util.BitSet;
37
import java.util.List;
38
import java.util.Locale;
39
import java.util.Objects;
40
import javax.annotation.Nullable;
41

42
/**
43
 * A not-quite-general-purpose representation of a Uniform Resource Identifier (URI), as defined by
44
 * <a href="https://datatracker.ietf.org/doc/html/rfc3986">RFC 3986</a>.
45
 *
46
 * <h1>The URI</h1>
47
 *
48
 * <p>A URI identifies a resource by its name or location or both. The resource could be a file,
49
 * service, or some other abstract entity.
50
 *
51
 * <h2>Examples</h2>
52
 *
53
 * <ul>
54
 *   <li><code>http://admin@example.com:8080/controlpanel?filter=users#settings</code>
55
 *   <li><code>ftp://[2001:db8::7]/docs/report.pdf</code>
56
 *   <li><code>file:///My%20Computer/Documents/letter.doc</code>
57
 *   <li><code>dns://8.8.8.8/storage.googleapis.com</code>
58
 *   <li><code>mailto:John.Doe@example.com</code>
59
 *   <li><code>tel:+1-206-555-1212</code>
60
 *   <li><code>urn:isbn:978-1492082798</code>
61
 * </ul>
62
 *
63
 * <h2>Limitations</h2>
64
 *
65
 * <p>This class aims to meet the needs of grpc-java itself and RPC related code that depend on it.
66
 * It isn't quite general-purpose. It definitely would not be suitable for building an HTTP user
67
 * agent or proxy server. In particular, it:
68
 *
69
 * <ul>
70
 *   <li>Can only represent a URI, not a "URI-reference" or "relative reference". In other words, a
71
 *       "scheme" is always required.
72
 *   <li>Has no knowledge of the particulars of any scheme, with respect to normalization and
73
 *       comparison. We don't know <code>https://google.com</code> is the same as <code>
74
 *       https://google.com:443</code>, that <code>file:///</code> is the same as <code>
75
 *       file://localhost</code>, or that <code>joe@example.com</code> is the same as <code>
76
 *       joe@EXAMPLE.COM</code>. No one class can or should know everything about every scheme so
77
 *       all this is better handled at a higher layer.
78
 *   <li>Implements {@link #equals(Object)} as a char-by-char comparison. Expect false negatives.
79
 *   <li>Does not support "IPvFuture" literal addresses.
80
 *   <li>Does not reflect how web browsers parse user input or the <a
81
 *       href="https://url.spec.whatwg.org/">URL Living Standard</a>.
82
 *   <li>Does not support different character encodings. Assumes UTF-8 in several places.
83
 * </ul>
84
 *
85
 * <h2>Migrating from RFC 2396 and {@link java.net.URI}</h2>
86
 *
87
 * <p>Those migrating from {@link java.net.URI} and/or its primary specification in RFC 2396 should
88
 * note some differences.
89
 *
90
 * <h3>Uniform Hierarchical Syntax</h3>
91
 *
92
 * <p>RFC 3986 unifies the older ideas of "hierarchical" and "opaque" URIs into a single generic
93
 * syntax. What RFC 2396 called an opaque "scheme-specific part" is always broken out by RFC 3986
94
 * into an authority and path hierarchy, followed by query and fragment components. Accordingly,
95
 * this class has only getters for those components but no {@link
96
 * java.net.URI#getSchemeSpecificPart()} analog.
97
 *
98
 * <p>The RFC 3986 definition of path is now more liberal to accommodate this:
99
 *
100
 * <ul>
101
 *   <li>Path doesn't have to start with a slash. For example, the path of <code>
102
 *       urn:isbn:978-1492082798</code> is <code>isbn:978-1492082798</code> even though it doesn't
103
 *       look much like a file system path.
104
 *   <li>The path can now be empty. So Android's <code>
105
 *       intent:#Intent;action=MAIN;category=LAUNCHER;end</code> is now a valid {@link Uri}. Even
106
 *       the scheme-only <code>about:</code> is now valid.
107
 * </ul>
108
 *
109
 * <p>The uniform syntax always understands what follows a '?' to be a query string. For example,
110
 * <code>mailto:me@example.com?subject=foo</code> now has a query component whereas RFC 2396
111
 * considered everything after the <code>mailto:</code> scheme to be opaque.
112
 *
113
 * <p>Same goes for fragment. <code>data:image/png;...#xywh=0,0,10,10</code> now has a fragment
114
 * whereas RFC 2396 considered everything after the scheme to be opaque.
115
 *
116
 * <h3>Uniform Authority Syntax</h3>
117
 *
118
 * <p>RFC 2396 tried to guess if an authority was a "server" (host:port) or "registry-based"
119
 * (arbitrary string) based on its contents. RFC 3986 expects every authority to look like
120
 * [userinfo@]host[:port] and loosens the definition of a "host" to accommodate. Accordingly, this
121
 * class has no equivalent to {@link java.net.URI#parseServerAuthority()} -- authority was parsed
122
 * into its components and checked for validity when the {@link Uri} was created.
123
 *
124
 * <h3>Other Specific Differences</h3>
125
 *
126
 * <p>RFC 2396 does not allow underscores in a host name, meaning {@link java.net.URI} switches to
127
 * opaque mode when it sees one. {@link Uri} does allow underscores in host, to accommodate
128
 * registries other than DNS. So <code>http://my_site.com:8080/index.html</code> now parses as a
129
 * host, port and path rather than a single opaque scheme-specific part.
130
 *
131
 * <p>{@link Uri} strictly *requires* square brackets in the query string and fragment to be
132
 * percent-encoded whereas RFC 2396 merely recommended doing so.
133
 *
134
 * <p>Other URx classes are "liberal in what they accept and strict in what they produce." {@link
135
 * Uri#parse(String)} and {@link Uri#create(String)}, however, are strict in what they accept and
136
 * transparent when asked to reproduce it via {@link Uri#toString()}. The former policy may be
137
 * appropriate for parsing user input or web content, but this class is meant for gRPC clients,
138
 * servers and plugins like name resolvers where human error at runtime is less likely and best
139
 * detected early. {@link java.net.URI#create(String)} is similarly strict, which makes migration
140
 * easy, except for the server/registry-based ambiguity addressed by {@link
141
 * java.net.URI#parseServerAuthority()}.
142
 *
143
 * <p>{@link java.net.URI} and {@link Uri} both support IPv6 literals in square brackets as defined
144
 * by RFC 2732.
145
 *
146
 * <p>{@link java.net.URI} supports IPv6 scope IDs but accepts and emits a non-standard syntax.
147
 * {@link Uri} implements the newer RFC 6874, which percent encodes scope IDs and the % delimiter
148
 * itself. RFC 9844 claims to obsolete RFC 6874 because web browsers would not support it. This
149
 * class implements RFC 6874 anyway, mostly to avoid creating a barrier to migration away from
150
 * {@link java.net.URI}.
151
 *
152
 * <p>Some URI components, e.g. scheme, are required while others may or may not be present, e.g.
153
 * authority. {@link Uri} is careful to preserve the distinction between an absent string component
154
 * (getter returns null) and one with an empty value (getter returns ""). {@link java.net.URI} makes
155
 * this distinction too, *except* when it comes to the authority and host components: {@link
156
 * java.net.URI#getAuthority()} and {@link java.net.URI#getHost()} return null when an authority is
157
 * absent, e.g. <code>file:/path</code> as expected. But these methods surprisingly also return null
158
 * when the authority is the empty string, e.g.<code>file:///path</code>. {@link Uri}'s getters
159
 * correctly return null and "" in these cases, respectively, as one would expect.
160
 */
161
@Internal
162
public final class Uri {
163
  // Components are stored percent-encoded, just as originally parsed for transparent parse/toString
164
  // round-tripping.
165
  private final String scheme; // != null since we don't support relative references.
166
  @Nullable private final String userInfo;
167
  @Nullable private final String host;
168
  @Nullable private final String port;
169
  private final String path; // In RFC 3986, path is always defined (but can be empty).
170
  @Nullable private final String query;
171
  @Nullable private final String fragment;
172

173
  private Uri(Builder builder) {
1✔
174
    this.scheme = checkNotNull(builder.scheme, "scheme");
1✔
175
    this.userInfo = builder.userInfo;
1✔
176
    this.host = builder.host;
1✔
177
    this.port = builder.port;
1✔
178
    this.path = builder.path;
1✔
179
    this.query = builder.query;
1✔
180
    this.fragment = builder.fragment;
1✔
181

182
    // Checks common to the parse() and Builder code paths.
183
    if (hasAuthority()) {
1✔
184
      if (!path.isEmpty() && !path.startsWith("/")) {
1✔
185
        throw new IllegalArgumentException("Has authority -- Non-empty path must start with '/'");
1✔
186
      }
187
    } else {
188
      if (path.startsWith("//")) {
1✔
189
        throw new IllegalArgumentException("No authority -- Path cannot start with '//'");
1✔
190
      }
191
    }
192
  }
1✔
193

194
  /**
195
   * Parses a URI from its string form.
196
   *
197
   * @throws URISyntaxException if 's' is not a valid RFC 3986 URI.
198
   */
199
  public static Uri parse(String s) throws URISyntaxException {
200
    try {
201
      return create(s);
1✔
202
    } catch (IllegalArgumentException e) {
1✔
203
      throw new URISyntaxException(s, e.getMessage());
1✔
204
    }
205
  }
206

207
  /**
208
   * Creates a URI from a string assumed to be valid.
209
   *
210
   * <p>Useful for defining URI constants in code. Not for user input.
211
   *
212
   * @throws IllegalArgumentException if 's' is not a valid RFC 3986 URI.
213
   */
214
  public static Uri create(String s) {
215
    Builder builder = new Builder();
1✔
216
    int i = 0;
1✔
217
    final int n = s.length();
1✔
218

219
    // 3.1. Scheme: Look for a ':' before '/', '?', or '#'.
220
    int schemeColon = -1;
1✔
221
    for (; i < n; ++i) {
1✔
222
      char c = s.charAt(i);
1✔
223
      if (c == ':') {
1✔
224
        schemeColon = i;
1✔
225
        break;
1✔
226
      } else if (c == '/' || c == '?' || c == '#') {
1✔
227
        break;
1✔
228
      }
229
    }
230
    if (schemeColon < 0) {
1✔
231
      throw new IllegalArgumentException("Missing required scheme.");
1✔
232
    }
233
    builder.setRawScheme(s.substring(0, schemeColon));
1✔
234

235
    // 3.2. Authority. Look for '//' then keep scanning until '/', '?', or '#'.
236
    i = schemeColon + 1;
1✔
237
    if (i + 1 < n && s.charAt(i) == '/' && s.charAt(i + 1) == '/') {
1✔
238
      // "//" just means we have an authority. Skip over it.
239
      i += 2;
1✔
240

241
      int authorityStart = i;
1✔
242
      for (; i < n; ++i) {
1✔
243
        char c = s.charAt(i);
1✔
244
        if (c == '/' || c == '?' || c == '#') {
1✔
245
          break;
1✔
246
        }
247
      }
248
      String authority = s.substring(authorityStart, i);
1✔
249

250
      // 3.2.1. UserInfo. Easy, because '@' cannot appear unencoded inside userinfo or host.
251
      int userInfoEnd = authority.indexOf('@');
1✔
252
      if (userInfoEnd >= 0) {
1✔
253
        builder.setRawUserInfo(authority.substring(0, userInfoEnd));
1✔
254
      }
255

256
      // 3.2.2/3. Host/Port.
257
      int hostStart = userInfoEnd >= 0 ? userInfoEnd + 1 : 0;
1✔
258
      int portStartColon = findPortStartColon(authority, hostStart);
1✔
259
      if (portStartColon < 0) {
1✔
260
        builder.setRawHost(authority.substring(hostStart, authority.length()));
1✔
261
      } else {
262
        builder.setRawHost(authority.substring(hostStart, portStartColon));
1✔
263
        builder.setRawPort(authority.substring(portStartColon + 1));
1✔
264
      }
265
    }
266

267
    // 3.3. Path: Whatever is left before '?' or '#'.
268
    int pathStart = i;
1✔
269
    for (; i < n; ++i) {
1✔
270
      char c = s.charAt(i);
1✔
271
      if (c == '?' || c == '#') {
1✔
272
        break;
1✔
273
      }
274
    }
275
    builder.setRawPath(s.substring(pathStart, i));
1✔
276

277
    // 3.4. Query, if we stopped at '?'.
278
    if (i < n && s.charAt(i) == '?') {
1✔
279
      i++; // Skip '?'
1✔
280
      int queryStart = i;
1✔
281
      for (; i < n; ++i) {
1✔
282
        char c = s.charAt(i);
1✔
283
        if (c == '#') {
1✔
284
          break;
1✔
285
        }
286
      }
287
      builder.setRawQuery(s.substring(queryStart, i));
1✔
288
    }
289

290
    // 3.5. Fragment, if we stopped at '#'.
291
    if (i < n && s.charAt(i) == '#') {
1✔
292
      ++i; // Skip '#'
1✔
293
      builder.setRawFragment(s.substring(i));
1✔
294
    }
295

296
    return builder.build();
1✔
297
  }
298

299
  private static int findPortStartColon(String authority, int hostStart) {
300
    for (int i = authority.length() - 1; i >= hostStart; --i) {
1✔
301
      char c = authority.charAt(i);
1✔
302
      if (c == ':') {
1✔
303
        return i;
1✔
304
      }
305
      if (c == ']') {
1✔
306
        // Hit the end of IP-literal. Any further colon is inside it and couldn't indicate a port.
307
        break;
1✔
308
      }
309
      if (!digitChars.get(c)) {
1✔
310
        // Found a non-digit, non-colon, non-bracket.
311
        // This means there is no valid port (e.g. host is "example.com")
312
        break;
1✔
313
      }
314
    }
315
    return -1;
1✔
316
  }
317

318
  // Checks a raw path for validity and parses it into segments. Let 'out' be null to just validate.
319
  private static void parseAssumedUtf8PathIntoSegments(
320
      String path, ImmutableList.Builder<String> out) {
321
    // Skip the first slash so it doesn't count as an empty segment at the start.
322
    // (e.g., "/a" -> ["a"], not ["", "a"])
323
    int start = path.startsWith("/") ? 1 : 0;
1✔
324

325
    for (int i = start; i < path.length(); ) {
1✔
326
      int nextSlash = path.indexOf('/', i);
1✔
327
      String segment;
328
      if (nextSlash >= 0) {
1✔
329
        // Typical segment case (e.g., "foo" in "/foo/bar").
330
        segment = path.substring(i, nextSlash);
1✔
331
        i = nextSlash + 1;
1✔
332
      } else {
333
        // Final segment case (e.g., "bar" in "/foo/bar").
334
        segment = path.substring(i);
1✔
335
        i = path.length();
1✔
336
      }
337
      if (out != null) {
1✔
338
        out.add(percentDecodeAssumedUtf8(segment));
1✔
339
      } else {
340
        checkPercentEncodedArg(segment, "path segment", pChars);
1✔
341
      }
342
    }
1✔
343

344
    // RFC 3986 says a trailing slash creates a final empty segment.
345
    // (e.g., "/foo/" -> ["foo", ""])
346
    if (path.endsWith("/") && out != null) {
1✔
347
      out.add("");
1✔
348
    }
349
  }
1✔
350

351
  /** Returns the scheme of this URI. */
352
  public String getScheme() {
353
    return scheme;
1✔
354
  }
355

356
  /**
357
   * Returns the percent-decoded "Authority" component of this URI, or null if not present.
358
   *
359
   * <p>NB: This method assumes the "host" component was encoded as UTF-8, as mandated by RFC 3986.
360
   * This method also assumes the "user information" part of authority was encoded as UTF-8,
361
   * although RFC 3986 doesn't specify an encoding.
362
   *
363
   * <p>Decoding errors are indicated by a {@code '\u005CuFFFD'} unicode replacement character in
364
   * the output. Callers who want to detect and handle errors in some other way should call {@link
365
   * #getRawAuthority()}, {@link #percentDecode(CharSequence)}, then decode the bytes for
366
   * themselves.
367
   */
368
  @Nullable
369
  public String getAuthority() {
370
    return percentDecodeAssumedUtf8(getRawAuthority());
1✔
371
  }
372

373
  private boolean hasAuthority() {
374
    return host != null;
1✔
375
  }
376

377
  /**
378
   * Returns the "authority" component of this URI in its originally parsed, possibly
379
   * percent-encoded form.
380
   */
381
  @Nullable
382
  public String getRawAuthority() {
383
    if (hasAuthority()) {
1✔
384
      StringBuilder sb = new StringBuilder();
1✔
385
      appendAuthority(sb);
1✔
386
      return sb.toString();
1✔
387
    }
388
    return null;
1✔
389
  }
390

391
  private void appendAuthority(StringBuilder sb) {
392
    if (userInfo != null) {
1✔
393
      sb.append(userInfo).append('@');
1✔
394
    }
395
    if (host != null) {
1✔
396
      sb.append(host);
1✔
397
    }
398
    if (port != null) {
1✔
399
      sb.append(':').append(port);
1✔
400
    }
401
  }
1✔
402

403
  /**
404
   * Returns the percent-decoded "User Information" component of this URI, or null if not present.
405
   *
406
   * <p>NB: This method *assumes* this component was encoded as UTF-8, although RFC 3986 doesn't
407
   * specify an encoding.
408
   *
409
   * <p>Decoding errors are indicated by a {@code '\u005CuFFFD'} unicode replacement character in
410
   * the output. Callers who want to detect and handle errors in some other way should call {@link
411
   * #getRawUserInfo()}, {@link #percentDecode(CharSequence)}, then decode the bytes for themselves.
412
   */
413
  @Nullable
414
  public String getUserInfo() {
415
    return percentDecodeAssumedUtf8(userInfo);
1✔
416
  }
417

418
  /**
419
   * Returns the "User Information" component of this URI in its originally parsed, possibly
420
   * percent-encoded form.
421
   */
422
  @Nullable
423
  public String getRawUserInfo() {
424
    return userInfo;
1✔
425
  }
426

427
  /**
428
   * Returns the percent-decoded "host" component of this URI, or null if not present.
429
   *
430
   * <p>This method assumes the host was encoded as UTF-8, as mandated by RFC 3986.
431
   *
432
   * <p>Decoding errors are indicated by a {@code '\u005CuFFFD'} unicode replacement character in
433
   * the output. Callers who want to detect and handle errors in some other way should call {@link
434
   * #getRawHost()}, {@link #percentDecode(CharSequence)}, then decode the bytes for themselves.
435
   */
436
  @Nullable
437
  public String getHost() {
438
    return percentDecodeAssumedUtf8(host);
1✔
439
  }
440

441
  /**
442
   * Returns the host component of this URI in its originally parsed, possibly percent-encoded form.
443
   */
444
  @Nullable
445
  public String getRawHost() {
446
    return host;
1✔
447
  }
448

449
  /** Returns the "port" component of this URI, or -1 if empty or not present. */
450
  public int getPort() {
451
    return port != null && !port.isEmpty() ? Integer.parseInt(port) : -1;
1✔
452
  }
453

454
  /** Returns the raw port component of this URI in its originally parsed form. */
455
  @Nullable
456
  public String getRawPort() {
457
    return port;
1✔
458
  }
459

460
  /**
461
   * Returns the (possibly empty) percent-decoded "path" component of this URI.
462
   *
463
   * <p>NB: This method *assumes* the path was encoded as UTF-8, although RFC 3986 doesn't specify
464
   * an encoding.
465
   *
466
   * <p>Decoding errors are indicated by a {@code '\u005CuFFFD'} unicode replacement character in
467
   * the output. Callers who want to detect and handle errors in some other way should call {@link
468
   * #getRawPath()}, {@link #percentDecode(CharSequence)}, then decode the bytes for themselves.
469
   *
470
   * <p>NB: Prefer {@link #getPathSegments()} because this method's decoding is lossy. For example,
471
   * consider these (different) URIs:
472
   *
473
   * <ul>
474
   *   <li>file:///home%2Ffolder/my%20file
475
   *   <li>file:///home/folder/my%20file
476
   * </ul>
477
   *
478
   * <p>Calling getPath() on each returns the same string: <code>/home/folder/my file</code>. You
479
   * can't tell whether the second '/' character is part of the first path segment or separates the
480
   * first and second path segments. This method only exists to ease migration from {@link
481
   * java.net.URI}.
482
   */
483
  public String getPath() {
484
    return percentDecodeAssumedUtf8(path);
1✔
485
  }
486

487
  /**
488
   * Returns this URI's path as a list of path segments not including the '/' segment delimiters.
489
   *
490
   * <p>Prefer this method over {@link #getPath()} because it preserves the distinction between
491
   * segment separators and literal '/'s within a path segment.
492
   *
493
   * <p>A trailing '/' delimiter in the path results in the empty string as the last element in the
494
   * returned list. For example, <code>file://localhost/foo/bar/</code> has path segments <code>
495
   * ["foo", "bar", ""]</code>
496
   *
497
   * <p>A leading '/' delimiter cannot be detected using this method. For example, both <code>
498
   * dns:example.com</code> and <code>dns:///example.com</code> have the same list of path segments:
499
   * <code>["example.com"]</code>. Use {@link #isPathAbsolute()} or {@link #isPathRootless()} to
500
   * distinguish these cases.
501
   *
502
   * <p>The returned list is immutable.
503
   */
504
  public List<String> getPathSegments() {
505
    // Returned list must be immutable but we intentionally keep guava out of the public API.
506
    ImmutableList.Builder<String> segmentsBuilder = ImmutableList.builder();
1✔
507
    parseAssumedUtf8PathIntoSegments(path, segmentsBuilder);
1✔
508
    return segmentsBuilder.build();
1✔
509
  }
510

511
  /**
512
   * Returns true iff this URI's path component starts with a path segment (rather than the '/'
513
   * segment delimiter).
514
   *
515
   * <p>The path of an RFC 3986 URI is either empty, absolute (starts with the '/' segment
516
   * delimiter) or rootless (starts with a path segment). For example, <code>tel:+1-206-555-1212
517
   * </code>, <code>mailto:me@example.com</code> and <code>urn:isbn:978-1492082798</code> all have
518
   * rootless paths. <code>mailto:%2Fdev%2Fnull@example.com</code> is also rootless because its
519
   * percent-encoded slashes are not segment delimiters but rather part of the first and only path
520
   * segment.
521
   *
522
   * <p>Contrast rootless paths with absolute ones (see {@link #isPathAbsolute()}.
523
   */
524
  public boolean isPathRootless() {
525
    return !path.isEmpty() && !path.startsWith("/");
1✔
526
  }
527

528
  /**
529
   * Returns true iff this URI's path component starts with the '/' segment delimiter (rather than a
530
   * path segment).
531
   *
532
   * <p>The path of an RFC 3986 URI is either empty, absolute (starts with the '/' segment
533
   * delimiter) or rootless (starts with a path segment). For example, <code>file:///resume.txt
534
   * </code>, <code>file:/resume.txt</code> and <code>file://localhost/</code> all have absolute
535
   * paths while <code>tel:+1-206-555-1212</code>'s path is not absolute. <code>
536
   * mailto:%2Fdev%2Fnull@example.com</code> is also not absolute because its percent-encoded
537
   * slashes are not segment delimiters but rather part of the first and only path segment.
538
   *
539
   * <p>Contrast absolute paths with rootless ones (see {@link #isPathRootless()}.
540
   *
541
   * <p>NB: The term "absolute" has two different meanings in RFC 3986 which are easily confused.
542
   * This method tests for a property of this URI's path component. Contrast with {@link
543
   * #isAbsolute()} which tests the URI itself for a different property.
544
   */
545
  public boolean isPathAbsolute() {
546
    return path.startsWith("/");
1✔
547
  }
548

549
  /**
550
   * Returns the path component of this URI in its originally parsed, possibly percent-encoded form.
551
   */
552
  public String getRawPath() {
553
    return path;
1✔
554
  }
555

556
  /**
557
   * Returns the percent-decoded "query" component of this URI, or null if not present.
558
   *
559
   * <p>NB: This method assumes the query was encoded as UTF-8, although RFC 3986 doesn't specify an
560
   * encoding.
561
   *
562
   * <p>Decoding errors are indicated by a {@code '\u005CuFFFD'} unicode replacement character in
563
   * the output. Callers who want to detect and handle errors in some other way should call {@link
564
   * #getRawQuery()}, {@link #percentDecode(CharSequence)}, then decode the bytes for themselves.
565
   */
566
  @Nullable
567
  public String getQuery() {
568
    return percentDecodeAssumedUtf8(query);
1✔
569
  }
570

571
  /**
572
   * Returns the query component of this URI in its originally parsed, possibly percent-encoded
573
   * form, without any leading '?' character.
574
   */
575
  @Nullable
576
  public String getRawQuery() {
577
    return query;
1✔
578
  }
579

580
  /**
581
   * Returns the percent-decoded "fragment" component of this URI, or null if not present.
582
   *
583
   * <p>NB: This method assumes the fragment was encoded as UTF-8, although RFC 3986 doesn't specify
584
   * an encoding.
585
   *
586
   * <p>Decoding errors are indicated by a {@code '\u005CuFFFD'} unicode replacement character in
587
   * the output. Callers who want to detect and handle errors in some other way should call {@link
588
   * #getRawFragment()}, {@link #percentDecode(CharSequence)}, then decode the bytes for themselves.
589
   */
590
  @Nullable
591
  public String getFragment() {
592
    return percentDecodeAssumedUtf8(fragment);
1✔
593
  }
594

595
  /**
596
   * Returns the fragment component of this URI in its original, possibly percent-encoded form, and
597
   * without any leading '#' character.
598
   */
599
  @Nullable
600
  public String getRawFragment() {
601
    return fragment;
1✔
602
  }
603

604
  /**
605
   * {@inheritDoc}
606
   *
607
   * <p>If this URI was created by {@link #parse(String)} or {@link #create(String)}, then the
608
   * returned string will match that original input exactly.
609
   */
610
  @Override
611
  public String toString() {
612
    // https://datatracker.ietf.org/doc/html/rfc3986#section-5.3
613
    StringBuilder sb = new StringBuilder();
1✔
614
    sb.append(scheme).append(':');
1✔
615
    if (hasAuthority()) {
1✔
616
      sb.append("//");
1✔
617
      appendAuthority(sb);
1✔
618
    }
619
    sb.append(path);
1✔
620
    if (query != null) {
1✔
621
      sb.append('?').append(query);
1✔
622
    }
623
    if (fragment != null) {
1✔
624
      sb.append('#').append(fragment);
1✔
625
    }
626
    return sb.toString();
1✔
627
  }
628

629
  /**
630
   * Returns true iff this URI has a scheme and an authority/path hierarchy, but no fragment.
631
   *
632
   * <p>All instances of {@link Uri} are RFC 3986 URIs, not "relative references", so this method is
633
   * equivalent to {@code getFragment() == null}. It mostly exists for compatibility with {@link
634
   * java.net.URI}.
635
   */
636
  public boolean isAbsolute() {
637
    return scheme != null && fragment == null;
1✔
638
  }
639

640
  /**
641
   * {@inheritDoc}
642
   *
643
   * <p>Two instances of {@link Uri} are equal if and only if they have the same string
644
   * representation, which RFC 3986 calls "Simple String Comparison" (6.2.1). Callers with a higher
645
   * layer expectation of equality (e.g. <code>http://some%2Dhost:80/foo/./bar.txt</code> ~= <code>
646
   * http://some-host/foo/bar.txt</code>) will experience false negatives.
647
   */
648
  @Override
649
  public boolean equals(Object otherObj) {
650
    if (!(otherObj instanceof Uri)) {
1✔
651
      return false;
1✔
652
    }
653
    Uri other = (Uri) otherObj;
1✔
654
    return Objects.equals(scheme, other.scheme)
1✔
655
        && Objects.equals(userInfo, other.userInfo)
1✔
656
        && Objects.equals(host, other.host)
1✔
657
        && Objects.equals(port, other.port)
1✔
658
        && Objects.equals(path, other.path)
1✔
659
        && Objects.equals(query, other.query)
1✔
660
        && Objects.equals(fragment, other.fragment);
1✔
661
  }
662

663
  @Override
664
  public int hashCode() {
665
    return Objects.hash(scheme, userInfo, host, port, path, query, fragment);
1✔
666
  }
667

668
  /** Returns a new Builder initialized with the fields of this URI. */
669
  public Builder toBuilder() {
670
    return new Builder(this);
1✔
671
  }
672

673
  /** Creates a new {@link Builder} with all fields uninitialized or set to their default values. */
674
  public static Builder newBuilder() {
675
    return new Builder();
1✔
676
  }
677

678
  /** Builder for {@link Uri}. */
679
  public static final class Builder {
680
    private String scheme;
681
    private String path = "";
1✔
682
    private String query;
683
    private String fragment;
684
    private String userInfo;
685
    private String host;
686
    private String port;
687

688
    private Builder() {}
1✔
689

690
    Builder(Uri prototype) {
1✔
691
      this.scheme = prototype.scheme;
1✔
692
      this.userInfo = prototype.userInfo;
1✔
693
      this.host = prototype.host;
1✔
694
      this.port = prototype.port;
1✔
695
      this.path = prototype.path;
1✔
696
      this.query = prototype.query;
1✔
697
      this.fragment = prototype.fragment;
1✔
698
    }
1✔
699

700
    /**
701
     * Sets the scheme, e.g. "https", "dns" or "xds".
702
     *
703
     * <p>This field is required.
704
     *
705
     * @return this, for fluent building
706
     * @throws IllegalArgumentException if the scheme is invalid.
707
     */
708
    @CanIgnoreReturnValue
709
    public Builder setScheme(String scheme) {
710
      return setRawScheme(scheme.toLowerCase(Locale.ROOT));
1✔
711
    }
712

713
    @CanIgnoreReturnValue
714
    Builder setRawScheme(String scheme) {
715
      if (scheme.isEmpty() || !alphaChars.get(scheme.charAt(0))) {
1✔
716
        throw new IllegalArgumentException("Scheme must start with an alphabetic char");
1✔
717
      }
718
      for (int i = 0; i < scheme.length(); i++) {
1✔
719
        char c = scheme.charAt(i);
1✔
720
        if (!schemeChars.get(c)) {
1✔
721
          throw new IllegalArgumentException("Invalid character in scheme at index " + i);
1✔
722
        }
723
      }
724
      this.scheme = scheme;
1✔
725
      return this;
1✔
726
    }
727

728
    /**
729
     * Specifies the new URI's path component as a string of zero or more '/' delimited segments.
730
     *
731
     * <p>Path segments can consist of any string of codepoints. Codepoints that can't be encoded
732
     * literally will be percent-encoded for you.
733
     *
734
     * <p>If a URI contains an authority component, then the path component must either be empty or
735
     * begin with a slash ("/") character. If a URI does not contain an authority component, then
736
     * the path cannot begin with two slash characters ("//").
737
     *
738
     * <p>This method interprets all '/' characters in 'path' as segment delimiters. If any of your
739
     * segments contain literal '/' characters, call {@link #setRawPath(String)} instead.
740
     *
741
     * <p>See <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.3">RFC 3986 3.3</a>
742
     * for more.
743
     *
744
     * <p>This field is required but can be empty (its default value).
745
     *
746
     * @param path the new path
747
     * @return this, for fluent building
748
     */
749
    @CanIgnoreReturnValue
750
    public Builder setPath(String path) {
751
      checkArgument(path != null, "Path can be empty but not null");
1✔
752
      this.path = percentEncode(path, pCharsAndSlash);
1✔
753
      return this;
1✔
754
    }
755

756
    /**
757
     * Specifies the new URI's path component as a string of zero or more '/' delimited segments.
758
     *
759
     * <p>Path segments can consist of any string of codepoints but the caller must first percent-
760
     * encode anything other than RFC 3986's "pchar" character class using UTF-8.
761
     *
762
     * <p>If a URI contains an authority component, then the path component must either be empty or
763
     * begin with a slash ("/") character. If a URI does not contain an authority component, then
764
     * the path cannot begin with two slash characters ("//").
765
     *
766
     * <p>This method interprets all '/' characters in 'path' as segment delimiters. If any of your
767
     * segments contain literal '/' characters, you must percent-encode them.
768
     *
769
     * <p>See <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.3">RFC 3986 3.3</a>
770
     * for more.
771
     *
772
     * <p>This field is required but can be empty (its default value).
773
     *
774
     * @param path the new path, a string consisting of characters from "pchar"
775
     * @return this, for fluent building
776
     */
777
    @CanIgnoreReturnValue
778
    public Builder setRawPath(String path) {
779
      checkArgument(path != null, "Path can be empty but not null");
1✔
780
      parseAssumedUtf8PathIntoSegments(path, null);
1✔
781
      this.path = path;
1✔
782
      return this;
1✔
783
    }
784

785
    /**
786
     * Specifies the query component of the new URI (not including the leading '?').
787
     *
788
     * <p>Query can contain any string of codepoints. Codepoints that can't be encoded literally
789
     * will be percent-encoded for you as UTF-8.
790
     *
791
     * <p>This field is optional.
792
     *
793
     * @param query the new query component, or null to clear this field
794
     * @return this, for fluent building
795
     */
796
    @CanIgnoreReturnValue
797
    public Builder setQuery(@Nullable String query) {
798
      this.query = percentEncode(query, queryChars);
1✔
799
      return this;
1✔
800
    }
801

802
    @CanIgnoreReturnValue
803
    Builder setRawQuery(String query) {
804
      checkPercentEncodedArg(query, "query", queryChars);
1✔
805
      this.query = query;
1✔
806
      return this;
1✔
807
    }
808

809
    /**
810
     * Specifies the fragment component of the new URI (not including the leading '#').
811
     *
812
     * <p>The fragment can contain any string of codepoints. Codepoints that can't be encoded
813
     * literally will be percent-encoded for you as UTF-8.
814
     *
815
     * <p>This field is optional.
816
     *
817
     * @param fragment the new fragment component, or null to clear this field
818
     * @return this, for fluent building
819
     */
820
    @CanIgnoreReturnValue
821
    public Builder setFragment(@Nullable String fragment) {
822
      this.fragment = percentEncode(fragment, fragmentChars);
1✔
823
      return this;
1✔
824
    }
825

826
    @CanIgnoreReturnValue
827
    Builder setRawFragment(String fragment) {
828
      checkPercentEncodedArg(fragment, "fragment", fragmentChars);
1✔
829
      this.fragment = fragment;
1✔
830
      return this;
1✔
831
    }
832

833
    /**
834
     * Set the "user info" component of the new URI, e.g. "username:password", not including the
835
     * trailing '@' character.
836
     *
837
     * <p>User info can contain any string of codepoints. Codepoints that can't be encoded literally
838
     * will be percent-encoded for you as UTF-8.
839
     *
840
     * <p>This field is optional.
841
     *
842
     * @param userInfo the new "user info" component, or null to clear this field
843
     * @return this, for fluent building
844
     */
845
    @CanIgnoreReturnValue
846
    public Builder setUserInfo(@Nullable String userInfo) {
847
      this.userInfo = percentEncode(userInfo, userInfoChars);
1✔
848
      return this;
1✔
849
    }
850

851
    @CanIgnoreReturnValue
852
    Builder setRawUserInfo(String userInfo) {
853
      checkPercentEncodedArg(userInfo, "userInfo", userInfoChars);
1✔
854
      this.userInfo = userInfo;
1✔
855
      return this;
1✔
856
    }
857

858
    /**
859
     * Specifies the "host" component of the new URI in its "registered name" form (usually DNS),
860
     * e.g. "server.com".
861
     *
862
     * <p>The registered name can contain any string of codepoints. Codepoints that can't be encoded
863
     * literally will be percent-encoded for you as UTF-8.
864
     *
865
     * <p>This field is optional.
866
     *
867
     * @param regName the new host component in "registered name" form, or null to clear this field
868
     * @return this, for fluent building
869
     */
870
    @CanIgnoreReturnValue
871
    public Builder setHost(@Nullable String regName) {
872
      if (regName != null) {
1✔
873
        regName = regName.toLowerCase(Locale.ROOT);
1✔
874
        regName = percentEncode(regName, regNameChars);
1✔
875
      }
876
      this.host = regName;
1✔
877
      return this;
1✔
878
    }
879

880
    /**
881
     * Specifies the "host" component of the new URI as an IP address.
882
     *
883
     * <p>This field is optional.
884
     *
885
     * @param addr the new "host" component in InetAddress form, or null to clear this field
886
     * @return this, for fluent building
887
     */
888
    @CanIgnoreReturnValue
889
    public Builder setHost(@Nullable InetAddress addr) {
890
      this.host = addr != null ? toUriString(addr) : null;
1✔
891
      return this;
1✔
892
    }
893

894
    private static String toUriString(InetAddress addr) {
895
      // InetAddresses.toUriString(addr) is almost enough but neglects RFC 6874 percent encoding.
896
      String inetAddrStr = InetAddresses.toUriString(addr);
1✔
897
      int percentIndex = inetAddrStr.indexOf('%');
1✔
898
      if (percentIndex < 0) {
1✔
899
        return inetAddrStr;
1✔
900
      }
901

902
      String scope = inetAddrStr.substring(percentIndex, inetAddrStr.length() - 1);
1✔
903
      return inetAddrStr.substring(0, percentIndex) + percentEncode(scope, unreservedChars) + "]";
1✔
904
    }
905

906
    @CanIgnoreReturnValue
907
    Builder setRawHost(String host) {
908
      if (host.startsWith("[") && host.endsWith("]")) {
1✔
909
        // IP-literal: Guava's isUriInetAddress() is almost enough but it doesn't check the scope.
910
        int percentIndex = host.indexOf('%');
1✔
911
        if (percentIndex > 0) {
1✔
912
          String scope = host.substring(percentIndex, host.length() - 1);
1✔
913
          checkPercentEncodedArg(scope, "scope", unreservedChars);
1✔
914
        }
915
      }
916
      // IP-literal validation is complicated so we delegate it to Guava. We use this particular
917
      // method of InetAddresses because it doesn't try to match interfaces on the local machine.
918
      // (The validity of a URI should be the same no matter which machine does the parsing.)
919
      // TODO(jdcormie): IPFuture
920
      if (!InetAddresses.isUriInetAddress(host)) {
1✔
921
        // Must be a "registered name".
922
        checkPercentEncodedArg(host, "host", regNameChars);
1✔
923
      }
924
      this.host = host;
1✔
925
      return this;
1✔
926
    }
927

928
    /**
929
     * Specifies the "port" component of the new URI, e.g. "8080".
930
     *
931
     * <p>The port can be any non-negative integer. A negative value represents "no port".
932
     *
933
     * <p>This field is optional.
934
     *
935
     * @param port the new "port" component, or -1 to clear this field
936
     * @return this, for fluent building
937
     */
938
    @CanIgnoreReturnValue
939
    public Builder setPort(int port) {
940
      this.port = port < 0 ? null : Integer.toString(port);
1✔
941
      return this;
1✔
942
    }
943

944
    @CanIgnoreReturnValue
945
    Builder setRawPort(String port) {
946
      if (port != null && !port.isEmpty()) {
1✔
947
        try {
948
          Integer.parseInt(port); // Result unused.
1✔
949
        } catch (NumberFormatException e) {
×
950
          throw new IllegalArgumentException("Invalid port", e);
×
951
        }
1✔
952
      }
953
      this.port = port;
1✔
954
      return this;
1✔
955
    }
956

957
    /** Builds a new instance of {@link Uri} as specified by the setters. */
958
    public Uri build() {
959
      checkState(scheme != null, "Missing required scheme.");
1✔
960
      if (host == null) {
1✔
961
        checkState(port == null, "Cannot set port without host.");
1✔
962
        checkState(userInfo == null, "Cannot set userInfo without host.");
1✔
963
      }
964
      return new Uri(this);
1✔
965
    }
966
  }
967

968
  /**
969
   * Decodes a string of characters in the range [U+0000, U+007F] to bytes.
970
   *
971
   * <p>Each percent-encoded sequence (e.g. "%F0" or "%2a", as defined by RFC 3986 2.1) is decoded
972
   * to the octet it encodes. Other characters are decoded to their code point's single byte value.
973
   * A literal % character must be encoded as %25.
974
   *
975
   * @throws IllegalArgumentException if 's' contains characters out of range or invalid percent
976
   *     encoding sequences.
977
   */
978
  public static ByteBuffer percentDecode(CharSequence s) {
979
    // This is large enough because each input character needs *at most* one byte of output.
980
    ByteBuffer outBuf = ByteBuffer.allocate(s.length());
1✔
981
    percentDecode(s, "input", null, outBuf);
1✔
982
    outBuf.flip();
1✔
983
    return outBuf;
1✔
984
  }
985

986
  private static void percentDecode(
987
      CharSequence s, String what, BitSet allowedChars, ByteBuffer outBuf) {
988
    for (int i = 0; i < s.length(); i++) {
1✔
989
      char c = s.charAt(i);
1✔
990
      if (c == '%') {
1✔
991
        if (i + 2 >= s.length()) {
1✔
992
          throw new IllegalArgumentException(
1✔
993
              "Invalid percent-encoding at index " + i + " of " + what + ": " + s);
994
        }
995
        int h1 = Character.digit(s.charAt(i + 1), 16);
1✔
996
        int h2 = Character.digit(s.charAt(i + 2), 16);
1✔
997
        if (h1 == -1 || h2 == -1) {
1✔
998
          throw new IllegalArgumentException(
1✔
999
              "Invalid hex digit in " + what + " at index " + i + " of: " + s);
1000
        }
1001
        if (outBuf != null) {
1✔
1002
          outBuf.put((byte) (h1 << 4 | h2));
1✔
1003
        }
1004
        i += 2;
1✔
1005
      } else if (allowedChars == null || allowedChars.get(c)) {
1✔
1006
        if (outBuf != null) {
1✔
1007
          outBuf.put((byte) c);
1✔
1008
        }
1009
      } else {
1010
        throw new IllegalArgumentException("Invalid character in " + what + " at index " + i);
1✔
1011
      }
1012
    }
1013
  }
1✔
1014

1015
  @Nullable
1016
  private static String percentDecodeAssumedUtf8(@Nullable String s) {
1017
    if (s == null || s.indexOf('%') == -1) {
1✔
1018
      return s;
1✔
1019
    }
1020

1021
    ByteBuffer utf8Bytes = percentDecode(s);
1✔
1022
    try {
1023
      return StandardCharsets.UTF_8
1✔
1024
          .newDecoder()
1✔
1025
          .onMalformedInput(CodingErrorAction.REPLACE)
1✔
1026
          .onUnmappableCharacter(CodingErrorAction.REPLACE)
1✔
1027
          .decode(utf8Bytes)
1✔
1028
          .toString();
1✔
1029
    } catch (CharacterCodingException e) {
×
1030
      throw new VerifyException(e); // Should not happen in REPLACE mode.
×
1031
    }
1032
  }
1033

1034
  @Nullable
1035
  private static String percentEncode(String s, BitSet allowedCodePoints) {
1036
    if (s == null) {
1✔
1037
      return null;
1✔
1038
    }
1039
    CharsetEncoder encoder =
1✔
1040
        StandardCharsets.UTF_8
1041
            .newEncoder()
1✔
1042
            .onMalformedInput(CodingErrorAction.REPORT)
1✔
1043
            .onUnmappableCharacter(CodingErrorAction.REPORT);
1✔
1044
    ByteBuffer utf8Bytes;
1045
    try {
1046
      utf8Bytes = encoder.encode(CharBuffer.wrap(s));
1✔
1047
    } catch (MalformedInputException e) {
1✔
1048
      throw new IllegalArgumentException("Malformed input", e); // Must be a broken surrogate pair.
1✔
1049
    } catch (CharacterCodingException e) {
×
1050
      throw new VerifyException(e); // Should not happen when encoding to UTF-8.
×
1051
    }
1✔
1052

1053
    StringBuilder sb = new StringBuilder();
1✔
1054
    while (utf8Bytes.hasRemaining()) {
1✔
1055
      int b = 0xff & utf8Bytes.get();
1✔
1056
      if (allowedCodePoints.get(b)) {
1✔
1057
        sb.append((char) b);
1✔
1058
      } else {
1059
        sb.append('%');
1✔
1060
        sb.append(hexDigitsByVal[(b & 0xF0) >> 4]);
1✔
1061
        sb.append(hexDigitsByVal[b & 0x0F]);
1✔
1062
      }
1063
    }
1✔
1064
    return sb.toString();
1✔
1065
  }
1066

1067
  private static void checkPercentEncodedArg(String s, String what, BitSet allowedChars) {
1068
    percentDecode(s, what, allowedChars, null);
1✔
1069
  }
1✔
1070

1071
  // See UriTest for how these were computed from the ABNF constants in RFC 3986.
1072
  static final BitSet digitChars = BitSet.valueOf(new long[] {0x3ff000000000000L});
1✔
1073
  static final BitSet alphaChars = BitSet.valueOf(new long[] {0L, 0x7fffffe07fffffeL});
1✔
1074
  // scheme        = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
1075
  static final BitSet schemeChars =
1✔
1076
      BitSet.valueOf(new long[] {0x3ff680000000000L, 0x7fffffe07fffffeL});
1✔
1077
  // unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
1078
  static final BitSet unreservedChars =
1✔
1079
      BitSet.valueOf(new long[] {0x3ff600000000000L, 0x47fffffe87fffffeL});
1✔
1080
  // gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
1081
  static final BitSet genDelimsChars =
1✔
1082
      BitSet.valueOf(new long[] {0x8400800800000000L, 0x28000001L});
1✔
1083
  // sub-delims    = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
1084
  static final BitSet subDelimsChars = BitSet.valueOf(new long[] {0x28001fd200000000L});
1✔
1085
  // reserved      = gen-delims / sub-delims
1086
  static final BitSet reservedChars = BitSet.valueOf(new long[] {0xac009fda00000000L, 0x28000001L});
1✔
1087
  // reg-name      = *( unreserved / pct-encoded / sub-delims )
1088
  static final BitSet regNameChars =
1✔
1089
      BitSet.valueOf(new long[] {0x2bff7fd200000000L, 0x47fffffe87fffffeL});
1✔
1090
  // userinfo      = *( unreserved / pct-encoded / sub-delims / ":" )
1091
  static final BitSet userInfoChars =
1✔
1092
      BitSet.valueOf(new long[] {0x2fff7fd200000000L, 0x47fffffe87fffffeL});
1✔
1093
  // pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
1094
  static final BitSet pChars =
1✔
1095
      BitSet.valueOf(new long[] {0x2fff7fd200000000L, 0x47fffffe87ffffffL});
1✔
1096
  static final BitSet pCharsAndSlash =
1✔
1097
      BitSet.valueOf(new long[] {0x2fffffd200000000L, 0x47fffffe87ffffffL});
1✔
1098
  //  query         = *( pchar / "/" / "?" )
1099
  static final BitSet queryChars =
1✔
1100
      BitSet.valueOf(new long[] {0xafffffd200000000L, 0x47fffffe87ffffffL});
1✔
1101
  // fragment      = *( pchar / "/" / "?" )
1102
  static final BitSet fragmentChars = queryChars;
1✔
1103

1104
  private static final char[] hexDigitsByVal = "0123456789ABCDEF".toCharArray();
1✔
1105
}
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