Skip to content

Commit fb71321

Browse files
Merge branch 'grpc:master' into master
2 parents 22ea5e5 + 12aaf88 commit fb71321

File tree

178 files changed

+4368
-2066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+4368
-2066
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module(
22
name = "grpc-java",
33
compatibility_level = 0,
44
repo_name = "io_grpc_grpc_java",
5-
version = "1.72.0-SNAPSHOT", # CURRENT_GRPC_VERSION
5+
version = "1.73.0-SNAPSHOT", # CURRENT_GRPC_VERSION
66
)
77

88
# GRPC_DEPS_START

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.71.0/examples) and the
48-
[Android example](https://github.com/grpc/grpc-java/tree/v1.71.0/examples/android)
47+
The [examples](https://github.com/grpc/grpc-java/tree/v1.72.0/examples) and the
48+
[Android example](https://github.com/grpc/grpc-java/tree/v1.72.0/examples/android)
4949
are standalone projects that showcase the usage of gRPC.
5050

5151
Download
@@ -56,18 +56,18 @@ 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.71.0</version>
59+
<version>1.72.0</version>
6060
<scope>runtime</scope>
6161
</dependency>
6262
<dependency>
6363
<groupId>io.grpc</groupId>
6464
<artifactId>grpc-protobuf</artifactId>
65-
<version>1.71.0</version>
65+
<version>1.72.0</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>io.grpc</groupId>
6969
<artifactId>grpc-stub</artifactId>
70-
<version>1.71.0</version>
70+
<version>1.72.0</version>
7171
</dependency>
7272
<dependency> <!-- necessary for Java 9+ -->
7373
<groupId>org.apache.tomcat</groupId>
@@ -79,18 +79,18 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
7979

8080
Or for Gradle with non-Android, add to your dependencies:
8181
```gradle
82-
runtimeOnly 'io.grpc:grpc-netty-shaded:1.71.0'
83-
implementation 'io.grpc:grpc-protobuf:1.71.0'
84-
implementation 'io.grpc:grpc-stub:1.71.0'
82+
runtimeOnly 'io.grpc:grpc-netty-shaded:1.72.0'
83+
implementation 'io.grpc:grpc-protobuf:1.72.0'
84+
implementation 'io.grpc:grpc-stub:1.72.0'
8585
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
8686
```
8787

8888
For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and
8989
`grpc-protobuf-lite` instead of `grpc-protobuf`:
9090
```gradle
91-
implementation 'io.grpc:grpc-okhttp:1.71.0'
92-
implementation 'io.grpc:grpc-protobuf-lite:1.71.0'
93-
implementation 'io.grpc:grpc-stub:1.71.0'
91+
implementation 'io.grpc:grpc-okhttp:1.72.0'
92+
implementation 'io.grpc:grpc-protobuf-lite:1.72.0'
93+
implementation 'io.grpc:grpc-stub:1.72.0'
9494
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
9595
```
9696

@@ -99,7 +99,7 @@ For [Bazel](https://bazel.build), you can either
9999
(with the GAVs from above), or use `@io_grpc_grpc_java//api` et al (see below).
100100

101101
[the JARs]:
102-
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.71.0
102+
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.72.0
103103

104104
Development snapshots are available in [Sonatypes's snapshot
105105
repository](https://oss.sonatype.org/content/repositories/snapshots/).
@@ -131,7 +131,7 @@ For protobuf-based codegen integrated with the Maven build system, you can use
131131
<configuration>
132132
<protocArtifact>com.google.protobuf:protoc:3.25.5:exe:${os.detected.classifier}</protocArtifact>
133133
<pluginId>grpc-java</pluginId>
134-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.71.0:exe:${os.detected.classifier}</pluginArtifact>
134+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.72.0:exe:${os.detected.classifier}</pluginArtifact>
135135
</configuration>
136136
<executions>
137137
<execution>
@@ -161,7 +161,7 @@ protobuf {
161161
}
162162
plugins {
163163
grpc {
164-
artifact = 'io.grpc:protoc-gen-grpc-java:1.71.0'
164+
artifact = 'io.grpc:protoc-gen-grpc-java:1.72.0'
165165
}
166166
}
167167
generateProtoTasks {
@@ -194,7 +194,7 @@ protobuf {
194194
}
195195
plugins {
196196
grpc {
197-
artifact = 'io.grpc:protoc-gen-grpc-java:1.71.0'
197+
artifact = 'io.grpc:protoc-gen-grpc-java:1.72.0'
198198
}
199199
}
200200
generateProtoTasks {

api/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies {
4747
testImplementation project(':grpc-core')
4848
testImplementation project(':grpc-testing')
4949
testImplementation libraries.guava.testlib
50+
testImplementation libraries.truth
5051

5152
signature (libraries.signature.java) {
5253
artifact {

api/src/context/java/io/grpc/Deadline.java

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
package io.grpc;
1818

19-
import java.util.Arrays;
19+
import static java.util.Objects.requireNonNull;
20+
2021
import java.util.Locale;
22+
import java.util.Objects;
2123
import java.util.concurrent.ScheduledExecutorService;
2224
import java.util.concurrent.ScheduledFuture;
2325
import java.util.concurrent.TimeUnit;
@@ -33,7 +35,7 @@
3335
* passed to the various components unambiguously.
3436
*/
3537
public final class Deadline implements Comparable<Deadline> {
36-
private static final SystemTicker SYSTEM_TICKER = new SystemTicker();
38+
private static final Ticker SYSTEM_TICKER = new SystemTicker();
3739
// nanoTime has a range of just under 300 years. Only allow up to 100 years in the past or future
3840
// to prevent wraparound as long as process runs for less than ~100 years.
3941
private static final long MAX_OFFSET = TimeUnit.DAYS.toNanos(100 * 365);
@@ -91,7 +93,7 @@ public static Deadline after(long duration, TimeUnit units) {
9193
* @since 1.24.0
9294
*/
9395
public static Deadline after(long duration, TimeUnit units, Ticker ticker) {
94-
checkNotNull(units, "units");
96+
requireNonNull(units, "units");
9597
return new Deadline(ticker, units.toNanos(duration), true);
9698
}
9799

@@ -191,8 +193,8 @@ public long timeRemaining(TimeUnit unit) {
191193
* @return {@link ScheduledFuture} which can be used to cancel execution of the task
192194
*/
193195
public ScheduledFuture<?> runOnExpiration(Runnable task, ScheduledExecutorService scheduler) {
194-
checkNotNull(task, "task");
195-
checkNotNull(scheduler, "scheduler");
196+
requireNonNull(task, "task");
197+
requireNonNull(scheduler, "scheduler");
196198
return scheduler.schedule(task, deadlineNanos - ticker.nanoTime(), TimeUnit.NANOSECONDS);
197199
}
198200

@@ -225,37 +227,27 @@ public String toString() {
225227
@Override
226228
public int compareTo(Deadline that) {
227229
checkTicker(that);
228-
long diff = this.deadlineNanos - that.deadlineNanos;
229-
if (diff < 0) {
230-
return -1;
231-
} else if (diff > 0) {
232-
return 1;
233-
}
234-
return 0;
230+
return Long.compare(this.deadlineNanos, that.deadlineNanos);
235231
}
236232

237233
@Override
238234
public int hashCode() {
239-
return Arrays.asList(this.ticker, this.deadlineNanos).hashCode();
235+
return Objects.hash(this.ticker, this.deadlineNanos);
240236
}
241237

242238
@Override
243-
public boolean equals(final Object o) {
244-
if (o == this) {
239+
public boolean equals(final Object object) {
240+
if (object == this) {
245241
return true;
246242
}
247-
if (!(o instanceof Deadline)) {
248-
return false;
249-
}
250-
251-
final Deadline other = (Deadline) o;
252-
if (this.ticker == null ? other.ticker != null : this.ticker != other.ticker) {
243+
if (!(object instanceof Deadline)) {
253244
return false;
254245
}
255-
if (this.deadlineNanos != other.deadlineNanos) {
246+
final Deadline that = (Deadline) object;
247+
if (this.ticker == null ? that.ticker != null : this.ticker != that.ticker) {
256248
return false;
257249
}
258-
return true;
250+
return this.deadlineNanos == that.deadlineNanos;
259251
}
260252

261253
/**
@@ -275,24 +267,17 @@ public boolean equals(final Object o) {
275267
* @since 1.24.0
276268
*/
277269
public abstract static class Ticker {
278-
/** Returns the number of nanoseconds since this source's epoch. */
270+
/** Returns the number of nanoseconds elapsed since this ticker's reference point in time. */
279271
public abstract long nanoTime();
280272
}
281273

282-
private static class SystemTicker extends Ticker {
274+
private static final class SystemTicker extends Ticker {
283275
@Override
284276
public long nanoTime() {
285277
return System.nanoTime();
286278
}
287279
}
288280

289-
private static <T> T checkNotNull(T reference, Object errorMessage) {
290-
if (reference == null) {
291-
throw new NullPointerException(String.valueOf(errorMessage));
292-
}
293-
return reference;
294-
}
295-
296281
private void checkTicker(Deadline other) {
297282
if (ticker != other.ticker) {
298283
throw new AssertionError(

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ final class ConfiguratorRegistry {
3333
@GuardedBy("this")
3434
private boolean wasConfiguratorsSet;
3535
@GuardedBy("this")
36-
private boolean configFrozen;
37-
@GuardedBy("this")
3836
private List<Configurator> configurators = Collections.emptyList();
37+
@GuardedBy("this")
38+
private int configuratorsCallCountBeforeSet = 0;
3939

4040
ConfiguratorRegistry() {}
4141

@@ -56,22 +56,31 @@ public static synchronized ConfiguratorRegistry getDefaultRegistry() {
5656
* @throws IllegalStateException if this method is called more than once
5757
*/
5858
public synchronized void setConfigurators(List<? extends Configurator> configurators) {
59-
if (configFrozen) {
59+
if (wasConfiguratorsSet) {
6060
throw new IllegalStateException("Configurators are already set");
6161
}
6262
this.configurators = Collections.unmodifiableList(new ArrayList<>(configurators));
63-
configFrozen = true;
6463
wasConfiguratorsSet = true;
6564
}
6665

6766
/**
6867
* Returns a list of the configurators in this registry.
6968
*/
7069
public synchronized List<Configurator> getConfigurators() {
71-
configFrozen = true;
70+
if (!wasConfiguratorsSet) {
71+
configuratorsCallCountBeforeSet++;
72+
}
7273
return configurators;
7374
}
7475

76+
/**
77+
* Returns the number of times getConfigurators() was called before
78+
* setConfigurators() was successfully invoked.
79+
*/
80+
public synchronized int getConfiguratorsCallCountBeforeSet() {
81+
return configuratorsCallCountBeforeSet;
82+
}
83+
7584
public synchronized boolean wasSetConfiguratorsCalled() {
7685
return wasConfiguratorsSet;
7786
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public abstract class InternalConfigSelector {
3535
= Attributes.Key.create("internal:io.grpc.config-selector");
3636

3737
// Use PickSubchannelArgs for SelectConfigArgs for now. May change over time.
38-
/** Selects the config for an PRC. */
38+
/** Selects the config for an RPC. */
3939
public abstract Result selectConfig(LoadBalancer.PickSubchannelArgs args);
4040

4141
public static final class Result {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ public static void configureServerBuilder(ServerBuilder<?> serverBuilder) {
4848
public static boolean wasSetConfiguratorsCalled() {
4949
return ConfiguratorRegistry.getDefaultRegistry().wasSetConfiguratorsCalled();
5050
}
51+
52+
public static int getConfiguratorsCallCountBeforeSet() {
53+
return ConfiguratorRegistry.getDefaultRegistry().getConfiguratorsCallCountBeforeSet();
54+
}
5155
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,6 @@ public abstract static class SubchannelPicker {
452452
* @since 1.3.0
453453
*/
454454
public abstract PickResult pickSubchannel(PickSubchannelArgs args);
455-
456-
/**
457-
* Tries to establish connections now so that the upcoming RPC may then just pick a ready
458-
* connection without having to connect first.
459-
*
460-
* <p>No-op if unsupported.
461-
*
462-
* @deprecated override {@link LoadBalancer#requestConnection} instead.
463-
* @since 1.11.0
464-
*/
465-
@Deprecated
466-
public void requestConnection() {}
467455
}
468456

469457
/**

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ public Status onResult2(ResolutionResult resolutionResult) {
275275
@Documented
276276
public @interface ResolutionResultAttr {}
277277

278+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/11989")
279+
@ResolutionResultAttr
280+
public static final Attributes.Key<String> ATTR_BACKEND_SERVICE =
281+
Attributes.Key.create("io.grpc.NameResolver.ATTR_BACKEND_SERVICE");
282+
278283
/**
279284
* Information that a {@link Factory} uses to create a {@link NameResolver}.
280285
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public Status getStatus() {
6666
return status == null ? Status.OK : status;
6767
}
6868

69+
/**
70+
* Note that StatusOr containing statuses, the equality comparision is delegated to
71+
* {@link Status#equals} which just does a reference equality check because equality on
72+
* Statuses is not well defined.
73+
* Instead, do comparison based on their Code with {@link Status#getCode}. The description and
74+
* cause of the Status are unlikely to be stable, and additional fields may be added to Status
75+
* in the future.
76+
*/
6977
@Override
7078
public boolean equals(Object other) {
7179
if (!(other instanceof StatusOr)) {

0 commit comments

Comments
 (0)