Skip to content

Commit dc2d2b1

Browse files
Merge branch 'grpc:master' into versionupgrade
2 parents 4bd09bd + b1bc0a9 commit dc2d2b1

File tree

294 files changed

+7129
-1331
lines changed

Some content is hidden

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

294 files changed

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

alts/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ java_library(
1818
"@com_google_protobuf//:protobuf_java",
1919
"@com_google_protobuf//:protobuf_java_util",
2020
artifact("com.google.code.findbugs:jsr305"),
21+
artifact("com.google.errorprone:error_prone_annotations"),
2122
artifact("com.google.guava:guava"),
2223
artifact("io.netty:netty-buffer"),
2324
artifact("io.netty:netty-codec"),

alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceGrpc.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ public HandshakerServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOption
6060
return HandshakerServiceStub.newStub(factory, channel);
6161
}
6262

63+
/**
64+
* Creates a new blocking-style stub that supports all types of calls on the service
65+
*/
66+
public static HandshakerServiceBlockingV2Stub newBlockingV2Stub(
67+
io.grpc.Channel channel) {
68+
io.grpc.stub.AbstractStub.StubFactory<HandshakerServiceBlockingV2Stub> factory =
69+
new io.grpc.stub.AbstractStub.StubFactory<HandshakerServiceBlockingV2Stub>() {
70+
@java.lang.Override
71+
public HandshakerServiceBlockingV2Stub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
72+
return new HandshakerServiceBlockingV2Stub(channel, callOptions);
73+
}
74+
};
75+
return HandshakerServiceBlockingV2Stub.newStub(factory, channel);
76+
}
77+
6378
/**
6479
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
6580
*/
@@ -157,6 +172,40 @@ public io.grpc.stub.StreamObserver<io.grpc.alts.internal.HandshakerReq> doHandsh
157172
/**
158173
* A stub to allow clients to do synchronous rpc calls to service HandshakerService.
159174
*/
175+
public static final class HandshakerServiceBlockingV2Stub
176+
extends io.grpc.stub.AbstractBlockingStub<HandshakerServiceBlockingV2Stub> {
177+
private HandshakerServiceBlockingV2Stub(
178+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
179+
super(channel, callOptions);
180+
}
181+
182+
@java.lang.Override
183+
protected HandshakerServiceBlockingV2Stub build(
184+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
185+
return new HandshakerServiceBlockingV2Stub(channel, callOptions);
186+
}
187+
188+
/**
189+
* <pre>
190+
* Handshaker service accepts a stream of handshaker request, returning a
191+
* stream of handshaker response. Client is expected to send exactly one
192+
* message with either client_start or server_start followed by one or more
193+
* messages with next. Each time client sends a request, the handshaker
194+
* service expects to respond. Client does not have to wait for service's
195+
* response before sending next request.
196+
* </pre>
197+
*/
198+
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
199+
public io.grpc.stub.BlockingClientCall<io.grpc.alts.internal.HandshakerReq, io.grpc.alts.internal.HandshakerResp>
200+
doHandshake() {
201+
return io.grpc.stub.ClientCalls.blockingBidiStreamingCall(
202+
getChannel(), getDoHandshakeMethod(), getCallOptions());
203+
}
204+
}
205+
206+
/**
207+
* A stub to allow clients to do limited synchronous rpc calls to service HandshakerService.
208+
*/
160209
public static final class HandshakerServiceBlockingStub
161210
extends io.grpc.stub.AbstractBlockingStub<HandshakerServiceBlockingStub> {
162211
private HandshakerServiceBlockingStub(

alts/src/main/java/io/grpc/alts/AltsContextUtil.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.grpc.alts;
1818

1919
import io.grpc.Attributes;
20+
import io.grpc.ClientCall;
2021
import io.grpc.ExperimentalApi;
2122
import io.grpc.ServerCall;
2223
import io.grpc.alts.internal.AltsInternalContext;
@@ -29,14 +30,36 @@ public final class AltsContextUtil {
2930
private AltsContextUtil() {}
3031

3132
/**
32-
* Creates a {@link AltsContext} from ALTS context information in the {@link ServerCall}.
33+
* Creates an {@link AltsContext} from ALTS context information in the {@link ServerCall}.
3334
*
3435
* @param call the {@link ServerCall} containing the ALTS information
3536
* @return the created {@link AltsContext}
3637
* @throws IllegalArgumentException if the {@link ServerCall} has no ALTS information.
3738
*/
3839
public static AltsContext createFrom(ServerCall<?, ?> call) {
39-
Object authContext = call.getAttributes().get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY);
40+
return createFrom(call.getAttributes());
41+
}
42+
43+
/**
44+
* Creates an {@link AltsContext} from ALTS context information in the {@link ClientCall}.
45+
*
46+
* @param call the {@link ClientCall} containing the ALTS information
47+
* @return the created {@link AltsContext}
48+
* @throws IllegalArgumentException if the {@link ClientCall} has no ALTS information.
49+
*/
50+
public static AltsContext createFrom(ClientCall<?, ?> call) {
51+
return createFrom(call.getAttributes());
52+
}
53+
54+
/**
55+
* Creates an {@link AltsContext} from ALTS context information in the {@link Attributes}.
56+
*
57+
* @param attributes the {@link Attributes} containing the ALTS information
58+
* @return the created {@link AltsContext}
59+
* @throws IllegalArgumentException if the {@link Attributes} has no ALTS information.
60+
*/
61+
public static AltsContext createFrom(Attributes attributes) {
62+
Object authContext = attributes.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY);
4063
if (!(authContext instanceof AltsInternalContext)) {
4164
throw new IllegalArgumentException("No ALTS context information found");
4265
}
@@ -53,6 +76,16 @@ public static boolean check(ServerCall<?, ?> call) {
5376
return check(call.getAttributes());
5477
}
5578

79+
/**
80+
* Checks if the {@link ClientCall} contains ALTS information.
81+
*
82+
* @param call the {@link ClientCall} to check
83+
* @return true, if the {@link ClientCall} contains ALTS information and false otherwise.
84+
*/
85+
public static boolean check(ClientCall<?, ?> call) {
86+
return check(call.getAttributes());
87+
}
88+
5689
/**
5790
* Checks if the {@link Attributes} contains ALTS information.
5891
*

alts/src/main/java/io/grpc/alts/internal/AsyncSemaphore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
package io.grpc.alts.internal;
1818

19+
import com.google.errorprone.annotations.concurrent.GuardedBy;
1920
import io.netty.channel.ChannelFuture;
2021
import io.netty.channel.ChannelHandlerContext;
2122
import io.netty.channel.ChannelPromise;
2223
import java.util.LinkedList;
2324
import java.util.Queue;
24-
import javax.annotation.concurrent.GuardedBy;
2525

2626
/** Provides a semaphore primitive, without blocking waiting on permits. */
2727
final class AsyncSemaphore {

alts/src/test/java/io/grpc/alts/AltsContextUtilTest.java

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.mockito.Mockito.when;
2525

2626
import io.grpc.Attributes;
27+
import io.grpc.ClientCall;
2728
import io.grpc.ServerCall;
2829
import io.grpc.alts.AltsContext.SecurityLevel;
2930
import io.grpc.alts.internal.AltsInternalContext;
@@ -37,27 +38,38 @@
3738
/** Unit tests for {@link AltsContextUtil}. */
3839
@RunWith(JUnit4.class)
3940
public class AltsContextUtilTest {
40-
41-
private final ServerCall<?,?> call = mock(ServerCall.class);
42-
4341
@Test
4442
public void check_noAttributeValue() {
45-
when(call.getAttributes()).thenReturn(Attributes.newBuilder().build());
43+
assertFalse(AltsContextUtil.check(Attributes.newBuilder().build()));
44+
}
4645

47-
assertFalse(AltsContextUtil.check(call));
46+
@Test
47+
public void check_unexpectedAttributeValueType() {
48+
assertFalse(AltsContextUtil.check(Attributes.newBuilder()
49+
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new Object())
50+
.build()));
4851
}
4952

5053
@Test
51-
public void contains_unexpectedAttributeValueType() {
54+
public void check_altsInternalContext() {
55+
assertTrue(AltsContextUtil.check(Attributes.newBuilder()
56+
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, AltsInternalContext.getDefaultInstance())
57+
.build()));
58+
}
59+
60+
@Test
61+
public void checkServer_altsInternalContext() {
62+
ServerCall<?,?> call = mock(ServerCall.class);
5263
when(call.getAttributes()).thenReturn(Attributes.newBuilder()
53-
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new Object())
64+
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, AltsInternalContext.getDefaultInstance())
5465
.build());
5566

56-
assertFalse(AltsContextUtil.check(call));
67+
assertTrue(AltsContextUtil.check(call));
5768
}
5869

5970
@Test
60-
public void contains_altsInternalContext() {
71+
public void checkClient_altsInternalContext() {
72+
ClientCall<?,?> call = mock(ClientCall.class);
6173
when(call.getAttributes()).thenReturn(Attributes.newBuilder()
6274
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, AltsInternalContext.getDefaultInstance())
6375
.build());
@@ -66,26 +78,57 @@ public void contains_altsInternalContext() {
6678
}
6779

6880
@Test
69-
public void from_altsInternalContext() {
81+
public void createFrom_altsInternalContext() {
7082
HandshakerResult handshakerResult =
7183
HandshakerResult.newBuilder()
7284
.setPeerIdentity(Identity.newBuilder().setServiceAccount("remote@peer"))
7385
.setLocalIdentity(Identity.newBuilder().setServiceAccount("local@peer"))
7486
.build();
75-
when(call.getAttributes()).thenReturn(Attributes.newBuilder()
76-
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new AltsInternalContext(handshakerResult))
77-
.build());
7887

79-
AltsContext context = AltsContextUtil.createFrom(call);
88+
AltsContext context = AltsContextUtil.createFrom(Attributes.newBuilder()
89+
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new AltsInternalContext(handshakerResult))
90+
.build());
8091
assertEquals("remote@peer", context.getPeerServiceAccount());
8192
assertEquals("local@peer", context.getLocalServiceAccount());
8293
assertEquals(SecurityLevel.INTEGRITY_AND_PRIVACY, context.getSecurityLevel());
8394
}
8495

8596
@Test(expected = IllegalArgumentException.class)
86-
public void from_noAttributeValue() {
87-
when(call.getAttributes()).thenReturn(Attributes.newBuilder().build());
97+
public void createFrom_noAttributeValue() {
98+
AltsContextUtil.createFrom(Attributes.newBuilder().build());
99+
}
88100

89-
AltsContextUtil.createFrom(call);
101+
@Test
102+
public void createFromServer_altsInternalContext() {
103+
HandshakerResult handshakerResult =
104+
HandshakerResult.newBuilder()
105+
.setPeerIdentity(Identity.newBuilder().setServiceAccount("remote@peer"))
106+
.setLocalIdentity(Identity.newBuilder().setServiceAccount("local@peer"))
107+
.build();
108+
109+
ServerCall<?,?> call = mock(ServerCall.class);
110+
when(call.getAttributes()).thenReturn(Attributes.newBuilder()
111+
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new AltsInternalContext(handshakerResult))
112+
.build());
113+
114+
AltsContext context = AltsContextUtil.createFrom(call);
115+
assertEquals("remote@peer", context.getPeerServiceAccount());
116+
}
117+
118+
@Test
119+
public void createFromClient_altsInternalContext() {
120+
HandshakerResult handshakerResult =
121+
HandshakerResult.newBuilder()
122+
.setPeerIdentity(Identity.newBuilder().setServiceAccount("remote@peer"))
123+
.setLocalIdentity(Identity.newBuilder().setServiceAccount("local@peer"))
124+
.build();
125+
126+
ClientCall<?,?> call = mock(ClientCall.class);
127+
when(call.getAttributes()).thenReturn(Attributes.newBuilder()
128+
.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new AltsInternalContext(handshakerResult))
129+
.build());
130+
131+
AltsContext context = AltsContextUtil.createFrom(call);
132+
assertEquals("remote@peer", context.getPeerServiceAccount());
90133
}
91134
}

android-interop-testing/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ description = 'gRPC: Android Integration Testing'
77

88
repositories {
99
google()
10-
mavenCentral()
1110
}
1211

1312
android {
@@ -74,7 +73,6 @@ dependencies {
7473
project(':grpc-protobuf-lite'),
7574
project(':grpc-stub'),
7675
project(':grpc-testing'),
77-
libraries.hdrhistogram,
7876
libraries.junit,
7977
libraries.truth,
8078
libraries.androidx.test.rules,

0 commit comments

Comments
 (0)