Skip to content

Commit e1ba7e2

Browse files
authored
Merge branch 'master' into feature/grpc-mirroring-unary
2 parents 55e43ba + 6a2028c commit e1ba7e2

37 files changed

Lines changed: 426 additions & 108 deletions

File tree

.gemini/config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
have_fun: false
2+
memory_config:
3+
disabled: false
4+
code_review:
5+
disable: false
6+
comment_severity_threshold: MEDIUM
7+
max_review_comments: -1
8+
pull_request_opened:
9+
help: false
10+
summary: false
11+
code_review: false
12+
include_drafts: false
13+
ignore_patterns: []

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
4141
"io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
4242
"io.perfmark:perfmark-api:0.27.0",
4343
"junit:junit:4.13.2",
44+
"org.mockito:mockito-core:4.4.0",
4445
"org.checkerframework:checker-qual:3.49.5",
4546
"org.codehaus.mojo:animal-sniffer-annotations:1.26",
4647
]

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ For a guided tour, take a look at the [quick start
4444
guide](https://grpc.io/docs/languages/java/quickstart) or the more explanatory [gRPC
4545
basics](https://grpc.io/docs/languages/java/basics).
4646

47-
The [examples](https://github.com/grpc/grpc-java/tree/v1.79.0/examples) and the
48-
[Android example](https://github.com/grpc/grpc-java/tree/v1.79.0/examples/android)
47+
The [examples](https://github.com/grpc/grpc-java/tree/v1.80.0/examples) and the
48+
[Android example](https://github.com/grpc/grpc-java/tree/v1.80.0/examples/android)
4949
are standalone projects that showcase the usage of gRPC.
5050

5151
Download
@@ -56,42 +56,42 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
5656
<dependency>
5757
<groupId>io.grpc</groupId>
5858
<artifactId>grpc-netty-shaded</artifactId>
59-
<version>1.79.0</version>
59+
<version>1.80.0</version>
6060
<scope>runtime</scope>
6161
</dependency>
6262
<dependency>
6363
<groupId>io.grpc</groupId>
6464
<artifactId>grpc-protobuf</artifactId>
65-
<version>1.79.0</version>
65+
<version>1.80.0</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>io.grpc</groupId>
6969
<artifactId>grpc-stub</artifactId>
70-
<version>1.79.0</version>
70+
<version>1.80.0</version>
7171
</dependency>
7272
```
7373

7474
Or for Gradle with non-Android, add to your dependencies:
7575
```gradle
76-
runtimeOnly 'io.grpc:grpc-netty-shaded:1.79.0'
77-
implementation 'io.grpc:grpc-protobuf:1.79.0'
78-
implementation 'io.grpc:grpc-stub:1.79.0'
76+
runtimeOnly 'io.grpc:grpc-netty-shaded:1.80.0'
77+
implementation 'io.grpc:grpc-protobuf:1.80.0'
78+
implementation 'io.grpc:grpc-stub:1.80.0'
7979
```
8080

8181
For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and
8282
`grpc-protobuf-lite` instead of `grpc-protobuf`:
8383
```gradle
84-
implementation 'io.grpc:grpc-okhttp:1.79.0'
85-
implementation 'io.grpc:grpc-protobuf-lite:1.79.0'
86-
implementation 'io.grpc:grpc-stub:1.79.0'
84+
implementation 'io.grpc:grpc-okhttp:1.80.0'
85+
implementation 'io.grpc:grpc-protobuf-lite:1.80.0'
86+
implementation 'io.grpc:grpc-stub:1.80.0'
8787
```
8888

8989
For [Bazel](https://bazel.build), you can either
9090
[use Maven](https://github.com/bazelbuild/rules_jvm_external)
9191
(with the GAVs from above), or use `@io_grpc_grpc_java//api` et al (see below).
9292

9393
[the JARs]:
94-
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.79.0
94+
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.80.0
9595

9696
Development snapshots are available in [Sonatypes's snapshot
9797
repository](https://central.sonatype.com/repository/maven-snapshots/).
@@ -123,7 +123,7 @@ For protobuf-based codegen integrated with the Maven build system, you can use
123123
<configuration>
124124
<protocArtifact>com.google.protobuf:protoc:3.25.8:exe:${os.detected.classifier}</protocArtifact>
125125
<pluginId>grpc-java</pluginId>
126-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.79.0:exe:${os.detected.classifier}</pluginArtifact>
126+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.80.0:exe:${os.detected.classifier}</pluginArtifact>
127127
</configuration>
128128
<executions>
129129
<execution>
@@ -153,7 +153,7 @@ protobuf {
153153
}
154154
plugins {
155155
grpc {
156-
artifact = 'io.grpc:protoc-gen-grpc-java:1.79.0'
156+
artifact = 'io.grpc:protoc-gen-grpc-java:1.80.0'
157157
}
158158
}
159159
generateProtoTasks {
@@ -186,7 +186,7 @@ protobuf {
186186
}
187187
plugins {
188188
grpc {
189-
artifact = 'io.grpc:protoc-gen-grpc-java:1.79.0'
189+
artifact = 'io.grpc:protoc-gen-grpc-java:1.80.0'
190190
}
191191
}
192192
generateProtoTasks {

android-interop-testing/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ dependencies {
7272
libraries.junit,
7373
libraries.truth,
7474
libraries.androidx.test.rules,
75+
libraries.androidx.test.core,
7576
libraries.opencensus.contrib.grpc.metrics
7677

7778
implementation (project(':grpc-services')) {
@@ -80,7 +81,7 @@ dependencies {
8081
}
8182

8283
androidTestImplementation libraries.androidx.test.ext.junit,
83-
'androidx.test:runner:1.4.0'
84+
libraries.androidx.test.runner
8485
}
8586

8687
// Checkstyle doesn't run automatically with android

api/BUILD.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,21 @@ java_library(
1515
artifact("com.google.guava:guava"),
1616
],
1717
)
18+
19+
java_library(
20+
name = "test_fixtures",
21+
testonly = 1,
22+
srcs = glob([
23+
"src/testFixtures/java/io/grpc/**/*.java",
24+
]),
25+
visibility = ["//xds:__pkg__"],
26+
deps = [
27+
"//core",
28+
artifact("com.google.code.findbugs:jsr305"),
29+
artifact("com.google.errorprone:error_prone_annotations"),
30+
artifact("com.google.guava:guava"),
31+
artifact("com.google.truth:truth"),
32+
artifact("junit:junit"),
33+
artifact("org.mockito:mockito-core"),
34+
],
35+
)

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,16 @@ public String toString() {
156156
private int recursionCount;
157157

158158
/**
159-
* Handles newly resolved server groups and metadata attributes from name resolution system.
160-
* {@code servers} contained in {@link EquivalentAddressGroup} should be considered equivalent
161-
* but may be flattened into a single list if needed.
162-
*
163-
* <p>Implementations should not modify the given {@code servers}.
159+
* Handles newly resolved addresses and metadata attributes from name resolution system.
160+
* Addresses in {@link EquivalentAddressGroup} should be considered equivalent but may be
161+
* flattened into a single list if needed.
164162
*
165163
* @param resolvedAddresses the resolved server addresses, attributes, and config.
166164
* @since 1.21.0
165+
*
166+
* @deprecated Use instead {@link #acceptResolvedAddresses(ResolvedAddresses)}
167167
*/
168+
@Deprecated
168169
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
169170
if (recursionCount++ == 0) {
170171
// Note that the information about the addresses actually being accepted will be lost
@@ -179,12 +180,10 @@ public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
179180
* EquivalentAddressGroup} addresses should be considered equivalent but may be flattened into a
180181
* single list if needed.
181182
*
182-
* <p>Implementations can choose to reject the given addresses by returning {@code false}.
183-
*
184-
* <p>Implementations should not modify the given {@code addresses}.
183+
* @param resolvedAddresses the resolved server addresses, attributes, and config
184+
* @return {@code Status.OK} if the resolved addresses were accepted, otherwise an error to report
185+
* to the name resolver
185186
*
186-
* @param resolvedAddresses the resolved server addresses, attributes, and config.
187-
* @return {@code true} if the resolved addresses were accepted. {@code false} if rejected.
188187
* @since 1.49.0
189188
*/
190189
public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
@@ -418,7 +417,16 @@ public void handleSubchannelState(
418417
*
419418
* <p>This method should always return a constant value. It's not specified when this will be
420419
* called.
420+
*
421+
* <p>Note that this method is only called when implementing {@code handleResolvedAddresses()}
422+
* instead of {@code acceptResolvedAddresses()}.
423+
*
424+
* @deprecated Instead of overwriting this and {@code handleResolvedAddresses()}, only
425+
* overwrite {@code acceptResolvedAddresses()} which indicates if the addresses provided
426+
* by the name resolver are acceptable with the {@code boolean} return value.
421427
*/
428+
@Deprecated
429+
@SuppressWarnings("InlineMeSuggester")
422430
public boolean canHandleEmptyAddressListFromNameResolution() {
423431
return false;
424432
}

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

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,7 @@ public static Uri create(String s) {
245245
break;
246246
}
247247
}
248-
String authority = s.substring(authorityStart, i);
249-
250-
// 3.2.1. UserInfo. Easy, because '@' cannot appear unencoded inside userinfo or host.
251-
int userInfoEnd = authority.indexOf('@');
252-
if (userInfoEnd >= 0) {
253-
builder.setRawUserInfo(authority.substring(0, userInfoEnd));
254-
}
255-
256-
// 3.2.2/3. Host/Port.
257-
int hostStart = userInfoEnd >= 0 ? userInfoEnd + 1 : 0;
258-
int portStartColon = findPortStartColon(authority, hostStart);
259-
if (portStartColon < 0) {
260-
builder.setRawHost(authority.substring(hostStart, authority.length()));
261-
} else {
262-
builder.setRawHost(authority.substring(hostStart, portStartColon));
263-
builder.setRawPort(authority.substring(portStartColon + 1));
264-
}
248+
builder.setRawAuthority(s.substring(authorityStart, i));
265249
}
266250

267251
// 3.3. Path: Whatever is left before '?' or '#'.
@@ -356,6 +340,15 @@ public String getScheme() {
356340
/**
357341
* Returns the percent-decoded "Authority" component of this URI, or null if not present.
358342
*
343+
* <p>NB: This method's decoding is lossy -- It only exists for compatibility with {@link
344+
* java.net.URI}. Prefer {@link #getRawAuthority()} or work instead with authority in terms of its
345+
* individual components ({@link #getUserInfo()}, {@link #getHost()} and {@link #getPort()}). The
346+
* problem with getAuthority() is that it returns the delimited concatenation of the percent-
347+
* decoded userinfo, host and port components. But both userinfo and host can contain the '@'
348+
* character, which becomes indistinguishable from the userinfo/host delimiter after decoding. For
349+
* example, URIs <code>scheme://x@y%40z</code> and <code>scheme://x%40y@z</code> have different
350+
* userinfo and host components but getAuthority() returns "x@y@z" for both of them.
351+
*
359352
* <p>NB: This method assumes the "host" component was encoded as UTF-8, as mandated by RFC 3986.
360353
* This method also assumes the "user information" part of authority was encoded as UTF-8,
361354
* although RFC 3986 doesn't specify an encoding.
@@ -954,6 +947,51 @@ Builder setRawPort(String port) {
954947
return this;
955948
}
956949

950+
/**
951+
* Specifies the userinfo, host and port URI components all at once using a single string.
952+
*
953+
* <p>This setter is "raw" in the sense that special characters in userinfo and host must be
954+
* passed in percent-encoded. See <a
955+
* href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2">RFC 3986 3.2</a> for the set
956+
* of characters allowed in each component of an authority.
957+
*
958+
* <p>There's no "cooked" method to set authority like for other URI components because
959+
* authority is a *compound* URI component whose userinfo, host and port components are
960+
* delimited with special characters '@' and ':'. But the first two of those components can
961+
* themselves contain these delimiters so we need percent-encoding to parse them unambiguously.
962+
*
963+
* @param authority an RFC 3986 authority string that will be used to set userinfo, host and
964+
* port, or null to clear all three of those components
965+
*/
966+
@CanIgnoreReturnValue
967+
public Builder setRawAuthority(@Nullable String authority) {
968+
if (authority == null) {
969+
setUserInfo(null);
970+
setHost((String) null);
971+
setPort(-1);
972+
} else {
973+
// UserInfo. Easy because '@' cannot appear unencoded inside userinfo or host.
974+
int userInfoEnd = authority.indexOf('@');
975+
if (userInfoEnd >= 0) {
976+
setRawUserInfo(authority.substring(0, userInfoEnd));
977+
} else {
978+
setUserInfo(null);
979+
}
980+
981+
// Host/Port.
982+
int hostStart = userInfoEnd >= 0 ? userInfoEnd + 1 : 0;
983+
int portStartColon = findPortStartColon(authority, hostStart);
984+
if (portStartColon < 0) {
985+
setRawHost(authority.substring(hostStart));
986+
setPort(-1);
987+
} else {
988+
setRawHost(authority.substring(hostStart, portStartColon));
989+
setRawPort(authority.substring(portStartColon + 1));
990+
}
991+
}
992+
return this;
993+
}
994+
957995
/** Builds a new instance of {@link Uri} as specified by the setters. */
958996
public Uri build() {
959997
checkState(scheme != null, "Missing required scheme.");

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,53 @@ public void builder_canClearAllOptionalFields() {
627627
assertThat(uri.toString()).isEqualTo("http:");
628628
}
629629

630+
@Test
631+
public void builder_canClearAuthorityComponents() {
632+
Uri uri = Uri.create("s://user@host:80/path").toBuilder().setRawAuthority(null).build();
633+
assertThat(uri.toString()).isEqualTo("s:/path");
634+
}
635+
636+
@Test
637+
public void builder_canSetEmptyAuthority() {
638+
Uri uri = Uri.create("s://user@host:80/path").toBuilder().setRawAuthority("").build();
639+
assertThat(uri.toString()).isEqualTo("s:///path");
640+
}
641+
642+
@Test
643+
public void builder_canSetRawAuthority() {
644+
Uri uri = Uri.newBuilder().setScheme("http").setRawAuthority("user@host:1234").build();
645+
assertThat(uri.getUserInfo()).isEqualTo("user");
646+
assertThat(uri.getHost()).isEqualTo("host");
647+
assertThat(uri.getPort()).isEqualTo(1234);
648+
}
649+
650+
@Test
651+
public void builder_setRawAuthorityPercentDecodes() {
652+
Uri uri =
653+
Uri.newBuilder()
654+
.setScheme("http")
655+
.setRawAuthority("user:user%40user@host%40host%3Ahost")
656+
.build();
657+
assertThat(uri.getUserInfo()).isEqualTo("user:user@user");
658+
assertThat(uri.getHost()).isEqualTo("host@host:host");
659+
assertThat(uri.getPort()).isEqualTo(-1);
660+
}
661+
662+
@Test
663+
public void builder_setRawAuthorityReplacesAllComponents() {
664+
Uri uri =
665+
Uri.newBuilder()
666+
.setScheme("http")
667+
.setUserInfo("user")
668+
.setHost("host")
669+
.setPort(1234)
670+
.setRawAuthority("other")
671+
.build();
672+
assertThat(uri.getUserInfo()).isNull();
673+
assertThat(uri.getHost()).isEqualTo("other");
674+
assertThat(uri.getPort()).isEqualTo(-1);
675+
}
676+
630677
@Test
631678
public void toString_percentEncodingMultiChar() throws URISyntaxException {
632679
Uri uri =

buildscripts/kokoro/android.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,18 @@ fi
132132

133133
# Update the statuses with the deltas
134134

135+
set +x
135136
gsutil cp gs://grpc-testing-secrets/github_credentials/oauth_token.txt ~/
136137

137138
desc="New DEX reference count: $(printf "%'d" "$new_dex_count") (delta: $(printf "%'d" "$dex_count_delta"))"
139+
echo "Setting status: $desc"
138140
curl -f -s -X POST -H "Content-Type: application/json" \
139141
-H "Authorization: token $(cat ~/oauth_token.txt | tr -d '\n')" \
140142
-d '{"state": "success", "context": "android/dex_diff", "description": "'"${desc}"'"}' \
141143
"https://api.github.com/repos/grpc/grpc-java/statuses/${KOKORO_GITHUB_PULL_REQUEST_COMMIT}"
142144

143145
desc="New APK size in bytes: $(printf "%'d" "$new_apk_size") (delta: $(printf "%'d" "$apk_size_delta"))"
146+
echo "Setting status: $desc"
144147
curl -f -s -X POST -H "Content-Type: application/json" \
145148
-H "Authorization: token $(cat ~/oauth_token.txt | tr -d '\n')" \
146149
-d '{"state": "success", "context": "android/apk_diff", "description": "'"${desc}"'"}' \

core/src/main/java/io/grpc/internal/ManagedChannelOrphanWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public ManagedChannel shutdown() {
6868
if (this.getClass() == null) {
6969
throw new AssertionError();
7070
}
71-
return result;
71+
return super.shutdown();
7272
}
7373

7474
@Override
@@ -79,7 +79,7 @@ public ManagedChannel shutdownNow() {
7979
if (this.getClass() == null) {
8080
throw new AssertionError();
8181
}
82-
return result;
82+
return super.shutdownNow();
8383
}
8484

8585
@VisibleForTesting

0 commit comments

Comments
 (0)