Skip to content

Commit 85cfb10

Browse files
committed
Merge branch 'shivaspeaks' of https://github.com/shivaspeaks/grpc-java into shivaspeaks
2 parents 89c6f8e + c10386a commit 85cfb10

File tree

149 files changed

+8313
-401
lines changed

Some content is hidden

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

149 files changed

+8313
-401
lines changed

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.perfmark:perfmark-api:0.27.0",
4242
"junit:junit:4.13.2",
4343
"org.apache.tomcat:annotations-api:6.0.53",
44+
"org.checkerframework:checker-qual:3.12.0",
4445
"org.codehaus.mojo:animal-sniffer-annotations:1.24",
4546
]
4647
# GRPC_DEPS_END

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.66.0/examples) and the
48-
[Android example](https://github.com/grpc/grpc-java/tree/v1.66.0/examples/android)
47+
The [examples](https://github.com/grpc/grpc-java/tree/v1.67.1/examples) and the
48+
[Android example](https://github.com/grpc/grpc-java/tree/v1.67.1/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.66.0</version>
59+
<version>1.67.1</version>
6060
<scope>runtime</scope>
6161
</dependency>
6262
<dependency>
6363
<groupId>io.grpc</groupId>
6464
<artifactId>grpc-protobuf</artifactId>
65-
<version>1.66.0</version>
65+
<version>1.67.1</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>io.grpc</groupId>
6969
<artifactId>grpc-stub</artifactId>
70-
<version>1.66.0</version>
70+
<version>1.67.1</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.66.0'
83-
implementation 'io.grpc:grpc-protobuf:1.66.0'
84-
implementation 'io.grpc:grpc-stub:1.66.0'
82+
runtimeOnly 'io.grpc:grpc-netty-shaded:1.67.1'
83+
implementation 'io.grpc:grpc-protobuf:1.67.1'
84+
implementation 'io.grpc:grpc-stub:1.67.1'
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.66.0'
92-
implementation 'io.grpc:grpc-protobuf-lite:1.66.0'
93-
implementation 'io.grpc:grpc-stub:1.66.0'
91+
implementation 'io.grpc:grpc-okhttp:1.67.1'
92+
implementation 'io.grpc:grpc-protobuf-lite:1.67.1'
93+
implementation 'io.grpc:grpc-stub:1.67.1'
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.66.0
102+
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.67.1
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.3:exe:${os.detected.classifier}</protocArtifact>
133133
<pluginId>grpc-java</pluginId>
134-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.66.0:exe:${os.detected.classifier}</pluginArtifact>
134+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.67.1: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.66.0'
164+
artifact = 'io.grpc:protoc-gen-grpc-java:1.67.1'
165165
}
166166
}
167167
generateProtoTasks {
@@ -194,7 +194,7 @@ protobuf {
194194
}
195195
plugins {
196196
grpc {
197-
artifact = 'io.grpc:protoc-gen-grpc-java:1.66.0'
197+
artifact = 'io.grpc:protoc-gen-grpc-java:1.67.1'
198198
}
199199
}
200200
generateProtoTasks {

RELEASING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ would be used to create all `v1.7` tags (e.g. `v1.7.0`, `v1.7.1`).
6565
```bash
6666
git fetch upstream
6767
git checkout -b v$MAJOR.$MINOR.x \
68-
$(git log --pretty=format:%H --grep "^Start $MAJOR.$((MINOR+1)).0 development cycle$" upstream/master)^
68+
$(git log --pretty=format:%H --grep "^Start $MAJOR.$((MINOR+1)).0 development cycle" upstream/master)^
6969
git push upstream v$MAJOR.$MINOR.x
7070
```
7171
5. Continue with Google-internal steps at go/grpc-java/releasing, but stop
@@ -132,7 +132,9 @@ Tagging the Release
132132
compiler/src/test{,Lite}/golden/Test{,Deprecated}Service.java.txt
133133
./gradlew build
134134
git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT"
135+
git push -u origin release-v$MAJOR.$MINOR.$PATCH
135136
```
137+
Raise a PR and set the base branch of the PR to v$MAJOR.$MINOR.x of the upstream grpc-java repo.
136138
6. Go through PR review and push the release tag and updated release branch to
137139
GitHub (DO NOT click the merge button on the GitHub page):
138140

android/src/main/java/io/grpc/android/UdsChannelBuilder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,15 @@ public static ManagedChannelBuilder<?> forPath(String path, Namespace namespace)
6868
throw new UnsupportedOperationException("OkHttpChannelBuilder not found on the classpath");
6969
}
7070
try {
71-
// Target 'dns:///localhost' is unused, but necessary as an argument for OkHttpChannelBuilder.
71+
// Target 'dns:///127.0.0.1' is unused, but necessary as an argument for OkHttpChannelBuilder.
72+
// An IP address is used instead of localhost to avoid a DNS lookup (see #11442). This should
73+
// work even if IPv4 is unavailable, as the DNS resolver doesn't need working IPv4 to parse an
74+
// IPv4 address. Unavailable IPv4 fails when we connect(), not at resolution time.
7275
// TLS is unsupported because Conscrypt assumes the platform Socket implementation to improve
7376
// performance by using the file descriptor directly.
7477
Object o = OKHTTP_CHANNEL_BUILDER_CLASS
7578
.getMethod("forTarget", String.class, ChannelCredentials.class)
76-
.invoke(null, "dns:///localhost", InsecureChannelCredentials.create());
79+
.invoke(null, "dns:///127.0.0.1", InsecureChannelCredentials.create());
7780
ManagedChannelBuilder<?> builder = OKHTTP_CHANNEL_BUILDER_CLASS.cast(o);
7881
OKHTTP_CHANNEL_BUILDER_CLASS
7982
.getMethod("socketFactory", SocketFactory.class)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ public abstract class LoadBalancer {
121121
HEALTH_CONSUMER_LISTENER_ARG_KEY =
122122
LoadBalancer.CreateSubchannelArgs.Key.create("internal:health-check-consumer-listener");
123123

124+
@Internal
125+
public static final LoadBalancer.CreateSubchannelArgs.Key<Boolean>
126+
DISABLE_SUBCHANNEL_RECONNECT_KEY =
127+
LoadBalancer.CreateSubchannelArgs.Key.createWithDefault(
128+
"internal:disable-subchannel-reconnect", Boolean.FALSE);
129+
124130
@Internal
125131
public static final Attributes.Key<Boolean>
126132
HAS_HEALTH_PRODUCER_LISTENER_KEY =

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

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121

2222
import com.google.common.base.MoreObjects;
23+
import com.google.common.base.MoreObjects.ToStringHelper;
2324
import com.google.common.base.Objects;
2425
import com.google.errorprone.annotations.InlineMe;
2526
import java.lang.annotation.Documented;
2627
import java.lang.annotation.Retention;
2728
import java.lang.annotation.RetentionPolicy;
2829
import java.net.URI;
29-
import java.util.ArrayList;
3030
import java.util.Collections;
3131
import java.util.List;
3232
import java.util.Map;
@@ -95,7 +95,8 @@ public void onError(Status error) {
9595

9696
@Override
9797
public void onResult(ResolutionResult resolutionResult) {
98-
listener.onAddresses(resolutionResult.getAddresses(), resolutionResult.getAttributes());
98+
listener.onAddresses(resolutionResult.getAddressesOrError().getValue(),
99+
resolutionResult.getAttributes());
99100
}
100101
});
101102
}
@@ -218,19 +219,21 @@ public abstract static class Listener2 implements Listener {
218219
@Override
219220
@Deprecated
220221
@InlineMe(
221-
replacement = "this.onResult(ResolutionResult.newBuilder().setAddresses(servers)"
222-
+ ".setAttributes(attributes).build())",
223-
imports = "io.grpc.NameResolver.ResolutionResult")
222+
replacement = "this.onResult2(ResolutionResult.newBuilder().setAddressesOrError("
223+
+ "StatusOr.fromValue(servers)).setAttributes(attributes).build())",
224+
imports = {"io.grpc.NameResolver.ResolutionResult", "io.grpc.StatusOr"})
224225
public final void onAddresses(
225226
List<EquivalentAddressGroup> servers, @ResolutionResultAttr Attributes attributes) {
226227
// TODO(jihuncho) need to promote Listener2 if we want to use ConfigOrError
227-
onResult(
228-
ResolutionResult.newBuilder().setAddresses(servers).setAttributes(attributes).build());
228+
onResult2(
229+
ResolutionResult.newBuilder().setAddressesOrError(
230+
StatusOr.fromValue(servers)).setAttributes(attributes).build());
229231
}
230232

231233
/**
232234
* Handles updates on resolved addresses and attributes. If
233-
* {@link ResolutionResult#getAddresses()} is empty, {@link #onError(Status)} will be called.
235+
* {@link ResolutionResult#getAddressesOrError()} is empty, {@link #onError(Status)} will be
236+
* called.
234237
*
235238
* @param resolutionResult the resolved server addresses, attributes, and Service Config.
236239
* @since 1.21.0
@@ -584,17 +587,17 @@ public abstract static class ServiceConfigParser {
584587
*/
585588
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770")
586589
public static final class ResolutionResult {
587-
private final List<EquivalentAddressGroup> addresses;
590+
private final StatusOr<List<EquivalentAddressGroup>> addressesOrError;
588591
@ResolutionResultAttr
589592
private final Attributes attributes;
590593
@Nullable
591594
private final ConfigOrError serviceConfig;
592595

593596
ResolutionResult(
594-
List<EquivalentAddressGroup> addresses,
597+
StatusOr<List<EquivalentAddressGroup>> addressesOrError,
595598
@ResolutionResultAttr Attributes attributes,
596599
ConfigOrError serviceConfig) {
597-
this.addresses = Collections.unmodifiableList(new ArrayList<>(addresses));
600+
this.addressesOrError = addressesOrError;
598601
this.attributes = checkNotNull(attributes, "attributes");
599602
this.serviceConfig = serviceConfig;
600603
}
@@ -615,7 +618,7 @@ public static Builder newBuilder() {
615618
*/
616619
public Builder toBuilder() {
617620
return newBuilder()
618-
.setAddresses(addresses)
621+
.setAddressesOrError(addressesOrError)
619622
.setAttributes(attributes)
620623
.setServiceConfig(serviceConfig);
621624
}
@@ -624,9 +627,20 @@ public Builder toBuilder() {
624627
* Gets the addresses resolved by name resolution.
625628
*
626629
* @since 1.21.0
630+
* @deprecated Will be superseded by getAddressesOrError
627631
*/
632+
@Deprecated
628633
public List<EquivalentAddressGroup> getAddresses() {
629-
return addresses;
634+
return addressesOrError.getValue();
635+
}
636+
637+
/**
638+
* Gets the addresses resolved by name resolution or the error in doing so.
639+
*
640+
* @since 1.65.0
641+
*/
642+
public StatusOr<List<EquivalentAddressGroup>> getAddressesOrError() {
643+
return addressesOrError;
630644
}
631645

632646
/**
@@ -652,11 +666,11 @@ public ConfigOrError getServiceConfig() {
652666

653667
@Override
654668
public String toString() {
655-
return MoreObjects.toStringHelper(this)
656-
.add("addresses", addresses)
657-
.add("attributes", attributes)
658-
.add("serviceConfig", serviceConfig)
659-
.toString();
669+
ToStringHelper stringHelper = MoreObjects.toStringHelper(this);
670+
stringHelper.add("addressesOrError", addressesOrError.toString());
671+
stringHelper.add("attributes", attributes);
672+
stringHelper.add("serviceConfigOrError", serviceConfig);
673+
return stringHelper.toString();
660674
}
661675

662676
/**
@@ -668,7 +682,7 @@ public boolean equals(Object obj) {
668682
return false;
669683
}
670684
ResolutionResult that = (ResolutionResult) obj;
671-
return Objects.equal(this.addresses, that.addresses)
685+
return Objects.equal(this.addressesOrError, that.addressesOrError)
672686
&& Objects.equal(this.attributes, that.attributes)
673687
&& Objects.equal(this.serviceConfig, that.serviceConfig);
674688
}
@@ -678,7 +692,7 @@ public boolean equals(Object obj) {
678692
*/
679693
@Override
680694
public int hashCode() {
681-
return Objects.hashCode(addresses, attributes, serviceConfig);
695+
return Objects.hashCode(addressesOrError, attributes, serviceConfig);
682696
}
683697

684698
/**
@@ -688,7 +702,8 @@ public int hashCode() {
688702
*/
689703
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770")
690704
public static final class Builder {
691-
private List<EquivalentAddressGroup> addresses = Collections.emptyList();
705+
private StatusOr<List<EquivalentAddressGroup>> addresses =
706+
StatusOr.fromValue(Collections.emptyList());
692707
private Attributes attributes = Attributes.EMPTY;
693708
@Nullable
694709
private ConfigOrError serviceConfig;
@@ -700,9 +715,21 @@ public static final class Builder {
700715
* Sets the addresses resolved by name resolution. This field is required.
701716
*
702717
* @since 1.21.0
718+
* @deprecated Will be superseded by setAddressesOrError
703719
*/
720+
@Deprecated
704721
public Builder setAddresses(List<EquivalentAddressGroup> addresses) {
705-
this.addresses = addresses;
722+
setAddressesOrError(StatusOr.fromValue(addresses));
723+
return this;
724+
}
725+
726+
/**
727+
* Sets the addresses resolved by name resolution or the error in doing so. This field is
728+
* required.
729+
* @param addresses Resolved addresses or an error in resolving addresses
730+
*/
731+
public Builder setAddressesOrError(StatusOr<List<EquivalentAddressGroup>> addresses) {
732+
this.addresses = checkNotNull(addresses, "StatusOr addresses cannot be null.");
706733
return this;
707734
}
708735

0 commit comments

Comments
 (0)