Skip to content

Commit dffaaf0

Browse files
committed
api: Remove io.grpc.Uri#isAbsolute()
Javadoc says this method only exists for compatibility with java.net.URI but the meaning of "absolute" actually changed from RFC 2396 to 3986 so isAbsolute() is more of a trap than a convenience. io.grpc.Uri intentionally only models URIs, not URI references. So under the RFC 2396 definition of absolute, every instance is absolute because it has a scheme. Removing isAbsolute() also avoids confusion with absolute paths, an entirely different concept.
1 parent 5185683 commit dffaaf0

2 files changed

Lines changed: 0 additions & 27 deletions

File tree

api/src/main/java/io/grpc/Uri.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,6 @@ public boolean isPathRootless() {
530530
* slashes are not segment delimiters but rather part of the first and only path segment.
531531
*
532532
* <p>Contrast absolute paths with rootless ones (see {@link #isPathRootless()}.
533-
*
534-
* <p>NB: The term "absolute" has two different meanings in RFC 3986 which are easily confused.
535-
* This method tests for a property of this URI's path component. Contrast with {@link
536-
* #isAbsolute()} which tests the URI itself for a different property.
537533
*/
538534
public boolean isPathAbsolute() {
539535
return path.startsWith("/");
@@ -629,16 +625,6 @@ public String toString() {
629625
return sb.toString();
630626
}
631627

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

643629
/**
644630
* {@inheritDoc}

api/src/test/java/io/grpc/UriTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public void parse_allComponents() throws URISyntaxException {
4545
assertThat(uri.getRawQuery()).isEqualTo("query");
4646
assertThat(uri.getFragment()).isEqualTo("fragment");
4747
assertThat(uri.toString()).isEqualTo("scheme://user@host:0443/path?query#fragment");
48-
assertThat(uri.isAbsolute()).isFalse(); // Has a fragment.
4948
assertThat(uri.isPathAbsolute()).isTrue();
5049
assertThat(uri.isPathRootless()).isFalse();
5150
}
@@ -59,7 +58,6 @@ public void parse_noAuthority() throws URISyntaxException {
5958
assertThat(uri.getRawQuery()).isEqualTo("query");
6059
assertThat(uri.getFragment()).isEqualTo("fragment");
6160
assertThat(uri.toString()).isEqualTo("scheme:/path?query#fragment");
62-
assertThat(uri.isAbsolute()).isFalse(); // Has a fragment.
6361
}
6462

6563
@Test
@@ -116,7 +114,6 @@ public void parse_noFragment() throws URISyntaxException {
116114
assertThat(uri.getRawQuery()).isEqualTo("query");
117115
assertThat(uri.getFragment()).isNull();
118116
assertThat(uri.toString()).isEqualTo("scheme://authority/path?query");
119-
assertThat(uri.isAbsolute()).isTrue();
120117
}
121118

122119
@Test
@@ -128,7 +125,6 @@ public void parse_emptyPathWithAuthority() throws URISyntaxException {
128125
assertThat(uri.getRawQuery()).isNull();
129126
assertThat(uri.getFragment()).isNull();
130127
assertThat(uri.toString()).isEqualTo("scheme://authority");
131-
assertThat(uri.isAbsolute()).isTrue();
132128
assertThat(uri.isPathAbsolute()).isFalse();
133129
assertThat(uri.isPathRootless()).isFalse();
134130
}
@@ -142,7 +138,6 @@ public void parse_rootless() throws URISyntaxException {
142138
assertThat(uri.getRawQuery()).isEqualTo("subject=raise");
143139
assertThat(uri.getFragment()).isNull();
144140
assertThat(uri.toString()).isEqualTo("mailto:ceo@company.com?subject=raise");
145-
assertThat(uri.isAbsolute()).isTrue();
146141
assertThat(uri.isPathAbsolute()).isFalse();
147142
assertThat(uri.isPathRootless()).isTrue();
148143
}
@@ -156,7 +151,6 @@ public void parse_emptyPath() throws URISyntaxException {
156151
assertThat(uri.getRawQuery()).isNull();
157152
assertThat(uri.getFragment()).isNull();
158153
assertThat(uri.toString()).isEqualTo("scheme:");
159-
assertThat(uri.isAbsolute()).isTrue();
160154
assertThat(uri.isPathAbsolute()).isFalse();
161155
assertThat(uri.isPathRootless()).isFalse();
162156
}
@@ -772,13 +766,6 @@ public void equalsAndHashCode() {
772766
.testEquals();
773767
}
774768

775-
@Test
776-
public void isAbsolute() {
777-
assertThat(Uri.create("scheme://authority/path").isAbsolute()).isTrue();
778-
assertThat(Uri.create("scheme://authority/path?query").isAbsolute()).isTrue();
779-
assertThat(Uri.create("scheme://authority/path#fragment").isAbsolute()).isFalse();
780-
assertThat(Uri.create("scheme://authority/path?query#fragment").isAbsolute()).isFalse();
781-
}
782769

783770
@Test
784771
public void serializedCharacterClasses_matchComputed() {

0 commit comments

Comments
 (0)