Skip to content

Commit 11adf6f

Browse files
Merge branch 'grpc:master' into Issue_fixed_1537
2 parents 163c958 + 53de8a7 commit 11adf6f

24 files changed

Lines changed: 324 additions & 361 deletions

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/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/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
/**

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ public void uncaughtException(Thread t, Throwable e) {
228228
@Nullable
229229
private LbHelperImpl lbHelper;
230230

231-
// Must ONLY be assigned from updateSubchannelPicker(), which is called from syncContext.
232-
// null if channel is in idle mode.
233-
@Nullable
234-
private volatile SubchannelPicker subchannelPicker;
235-
236231
// Must be accessed from the syncContext
237232
private boolean panicMode;
238233

@@ -259,8 +254,7 @@ public void uncaughtException(Thread t, Throwable e) {
259254
// Channel's shutdown process:
260255
// 1. shutdown(): stop accepting new calls from applications
261256
// 1a shutdown <- true
262-
// 1b subchannelPicker <- null
263-
// 1c delayedTransport.shutdown()
257+
// 1b delayedTransport.shutdown()
264258
// 2. delayedTransport terminated: stop stream-creation functionality
265259
// 2a terminating <- true
266260
// 2b loadBalancer.shutdown()
@@ -393,7 +387,6 @@ private void shutdownNameResolverAndLoadBalancer(boolean channelIsActive) {
393387
lbHelper.lb.shutdown();
394388
lbHelper = null;
395389
}
396-
subchannelPicker = null;
397390
}
398391

399392
/**
@@ -804,7 +797,6 @@ boolean isInPanicMode() {
804797

805798
// Called from syncContext
806799
private void updateSubchannelPicker(SubchannelPicker newPicker) {
807-
subchannelPicker = newPicker;
808800
delayedTransport.reprocess(newPicker);
809801
}
810802

@@ -1228,9 +1220,6 @@ final class RequestConnection implements Runnable {
12281220
@Override
12291221
public void run() {
12301222
exitIdleMode();
1231-
if (subchannelPicker != null) {
1232-
subchannelPicker.requestConnection();
1233-
}
12341223
if (lbHelper != null) {
12351224
lbHelper.lb.requestConnection();
12361225
}

core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,6 @@ public void getState_withRequestConnect_IdleWithLbRunning() {
25902590

25912591
assertEquals(IDLE, channel.getState(true));
25922592
verify(mockLoadBalancerProvider).newLoadBalancer(any(Helper.class));
2593-
verify(mockPicker).requestConnection();
25942593
verify(mockLoadBalancer).requestConnection();
25952594
}
25962595

xds/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ tasks.named("checkstyleThirdparty").configure {
133133

134134
tasks.named("compileJava").configure {
135135
it.options.compilerArgs += [
136-
// TODO: remove
137-
"-Xlint:-deprecation",
138136
// only has AutoValue annotation processor
139137
"-Xlint:-processing",
140138
]

xds/src/main/java/io/grpc/xds/ClusterResolverLoadBalancer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ public Status onResult2(final ResolutionResult resolutionResult) {
673673
resolutionResult.getAddressesOrError();
674674
if (addressesOrError.hasValue()) {
675675
backoffPolicy = null; // reset backoff sequence if succeeded
676-
for (EquivalentAddressGroup eag : resolutionResult.getAddresses()) {
676+
for (EquivalentAddressGroup eag : addressesOrError.getValue()) {
677677
// No weight attribute is attached, all endpoint-level LB policy should be able
678678
// to handle such it.
679679
String localityName = localityName(LOGICAL_DNS_CLUSTER_LOCALITY);

0 commit comments

Comments
 (0)