Skip to content

Commit eee4f0f

Browse files
committed
Merge branch 'master' of github.com:grpc/grpc-java into impl/zero_copy_into_protobuf_2
2 parents c46eb73 + 0936703 commit eee4f0f

File tree

140 files changed

+7757
-1430
lines changed

Some content is hidden

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

140 files changed

+7757
-1430
lines changed

README.md

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

33-
The [examples](https://github.com/grpc/grpc-java/tree/v1.31.0/examples) and the
34-
[Android example](https://github.com/grpc/grpc-java/tree/v1.31.0/examples/android)
33+
The [examples](https://github.com/grpc/grpc-java/tree/v1.31.1/examples) and the
34+
[Android example](https://github.com/grpc/grpc-java/tree/v1.31.1/examples/android)
3535
are standalone projects that showcase the usage of gRPC.
3636

3737
Download
@@ -42,17 +42,17 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
4242
<dependency>
4343
<groupId>io.grpc</groupId>
4444
<artifactId>grpc-netty-shaded</artifactId>
45-
<version>1.31.0</version>
45+
<version>1.31.1</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>io.grpc</groupId>
4949
<artifactId>grpc-protobuf</artifactId>
50-
<version>1.31.0</version>
50+
<version>1.31.1</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>io.grpc</groupId>
5454
<artifactId>grpc-stub</artifactId>
55-
<version>1.31.0</version>
55+
<version>1.31.1</version>
5656
</dependency>
5757
<dependency> <!-- necessary for Java 9+ -->
5858
<groupId>org.apache.tomcat</groupId>
@@ -64,23 +64,23 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
6464

6565
Or for Gradle with non-Android, add to your dependencies:
6666
```gradle
67-
implementation 'io.grpc:grpc-netty-shaded:1.31.0'
68-
implementation 'io.grpc:grpc-protobuf:1.31.0'
69-
implementation 'io.grpc:grpc-stub:1.31.0'
67+
implementation 'io.grpc:grpc-netty-shaded:1.31.1'
68+
implementation 'io.grpc:grpc-protobuf:1.31.1'
69+
implementation 'io.grpc:grpc-stub:1.31.1'
7070
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
7171
```
7272

7373
For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and
7474
`grpc-protobuf-lite` instead of `grpc-protobuf`:
7575
```gradle
76-
implementation 'io.grpc:grpc-okhttp:1.31.0'
77-
implementation 'io.grpc:grpc-protobuf-lite:1.31.0'
78-
implementation 'io.grpc:grpc-stub:1.31.0'
76+
implementation 'io.grpc:grpc-okhttp:1.31.1'
77+
implementation 'io.grpc:grpc-protobuf-lite:1.31.1'
78+
implementation 'io.grpc:grpc-stub:1.31.1'
7979
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
8080
```
8181

8282
[the JARs]:
83-
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.31.0
83+
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.31.1
8484

8585
Development snapshots are available in [Sonatypes's snapshot
8686
repository](https://oss.sonatype.org/content/repositories/snapshots/).
@@ -112,7 +112,7 @@ For protobuf-based codegen integrated with the Maven build system, you can use
112112
<configuration>
113113
<protocArtifact>com.google.protobuf:protoc:3.12.0:exe:${os.detected.classifier}</protocArtifact>
114114
<pluginId>grpc-java</pluginId>
115-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.31.0:exe:${os.detected.classifier}</pluginArtifact>
115+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.31.1:exe:${os.detected.classifier}</pluginArtifact>
116116
</configuration>
117117
<executions>
118118
<execution>
@@ -142,7 +142,7 @@ protobuf {
142142
}
143143
plugins {
144144
grpc {
145-
artifact = 'io.grpc:protoc-gen-grpc-java:1.31.0'
145+
artifact = 'io.grpc:protoc-gen-grpc-java:1.31.1'
146146
}
147147
}
148148
generateProtoTasks {

RELEASING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Now we need to update gh-pages with the new Javadoc:
225225

226226
```bash
227227
git checkout gh-pages
228-
git pull --ff-only
228+
git pull --ff-only upstream gh-pages
229229
rm -r javadoc/
230230
wget -O grpc-all-javadoc.jar "http://search.maven.org/remotecontent?filepath=io/grpc/grpc-all/$MAJOR.$MINOR.$PATCH/grpc-all-$MAJOR.$MINOR.$PATCH-javadoc.jar"
231231
unzip -d javadoc grpc-all-javadoc.jar

SECURITY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ grpc-netty version | netty-handler version | netty-tcnative-boringssl-static ver
403403
1.23.x-1.24.x | 4.1.38.Final | 2.0.25.Final
404404
1.25.x-1.27.x | 4.1.42.Final | 2.0.26.Final
405405
1.28.x | 4.1.45.Final | 2.0.28.Final
406-
1.29.x- | 4.1.48.Final | 2.0.30.Final
406+
1.29.x-1.31.x | 4.1.48.Final | 2.0.30.Final
407+
1.32.x- | 4.1.51.Final | 2.0.31.Final
407408

408409
_(grpc-netty-shaded avoids issues with keeping these versions in sync.)_
409410

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

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

1919
import com.google.common.base.Preconditions;
20+
import java.nio.Buffer;
2021
import java.nio.ByteBuffer;
2122
import java.nio.ByteOrder;
2223
import java.security.GeneralSecurityException;
@@ -63,10 +64,10 @@ static ByteBuffer toFrame(ByteBuffer input, int dataSize) throws GeneralSecurity
6364
}
6465
Producer producer = new Producer();
6566
ByteBuffer inputAlias = input.duplicate();
66-
inputAlias.limit(input.position() + dataSize);
67+
((Buffer) inputAlias).limit(input.position() + dataSize);
6768
producer.readBytes(inputAlias);
6869
producer.flush();
69-
input.position(inputAlias.position());
70+
((Buffer) input).position(inputAlias.position());
7071
ByteBuffer output = producer.getRawFrame();
7172
return output;
7273
}
@@ -166,10 +167,10 @@ void flush() throws GeneralSecurityException {
166167
int frameLength = buffer.position() + getFrameSuffixLength();
167168

168169
// Set the limit and move to the start.
169-
buffer.flip();
170+
((Buffer) buffer).flip();
170171

171172
// Advance the limit to allow a crypto suffix.
172-
buffer.limit(buffer.limit() + getFrameSuffixLength());
173+
((Buffer) buffer).limit(buffer.limit() + getFrameSuffixLength());
173174

174175
// Write the data length and the message type.
175176
int dataLength = frameLength - FRAME_LENGTH_HEADER_SIZE;
@@ -178,17 +179,17 @@ void flush() throws GeneralSecurityException {
178179
buffer.putInt(MESSAGE_TYPE);
179180

180181
// Move the position back to 0, the frame is ready.
181-
buffer.position(0);
182+
((Buffer) buffer).position(0);
182183
isComplete = true;
183184
}
184185

185186
/** Resets the state, preparing to construct a new frame. Must be called between frames. */
186187
private void reset() {
187-
buffer.clear();
188+
((Buffer) buffer).clear();
188189

189190
// Save some space for framing, we'll fill that in later.
190-
buffer.position(getFramePrefixLength());
191-
buffer.limit(buffer.limit() - getFrameSuffixLength());
191+
((Buffer) buffer).position(getFramePrefixLength());
192+
((Buffer) buffer).limit(buffer.limit() - getFrameSuffixLength());
192193

193194
isComplete = false;
194195
}
@@ -279,7 +280,7 @@ public boolean readBytes(ByteBuffer input) throws GeneralSecurityException {
279280
// internal buffer is large enough.
280281
if (buffer.position() == FRAME_LENGTH_HEADER_SIZE && input.hasRemaining()) {
281282
ByteBuffer bufferAlias = buffer.duplicate();
282-
bufferAlias.flip();
283+
((Buffer) bufferAlias).flip();
283284
bufferAlias.order(ByteOrder.LITTLE_ENDIAN);
284285
int dataLength = bufferAlias.getInt();
285286
if (dataLength < FRAME_MESSAGE_TYPE_HEADER_SIZE || dataLength > MAX_DATA_LENGTH) {
@@ -292,15 +293,15 @@ public boolean readBytes(ByteBuffer input) throws GeneralSecurityException {
292293
buffer.order(ByteOrder.LITTLE_ENDIAN);
293294
buffer.putInt(dataLength);
294295
}
295-
buffer.limit(frameLength);
296+
((Buffer) buffer).limit(frameLength);
296297
}
297298

298299
// TODO: Similarly extract and check message type.
299300

300301
// Read the remaining data into the internal buffer.
301302
copy(buffer, input);
302303
if (!buffer.hasRemaining()) {
303-
buffer.flip();
304+
((Buffer) buffer).flip();
304305
isComplete = true;
305306
}
306307
return isComplete;
@@ -323,7 +324,7 @@ public boolean isComplete() {
323324

324325
/** Resets the state, preparing to parse a new frame. Must be called between frames. */
325326
private void reset() {
326-
buffer.clear();
327+
((Buffer) buffer).clear();
327328
isComplete = false;
328329
}
329330

@@ -356,9 +357,9 @@ private static void copy(ByteBuffer dst, ByteBuffer src) {
356357
} else {
357358
int count = Math.min(dst.remaining(), src.remaining());
358359
ByteBuffer slice = src.slice();
359-
slice.limit(count);
360+
((Buffer) slice).limit(count);
360361
dst.put(slice);
361-
src.position(src.position() + count);
362+
((Buffer) src).position(src.position() + count);
362363
}
363364
}
364365
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.grpc.Status;
2424
import io.grpc.alts.internal.HandshakerServiceGrpc.HandshakerServiceStub;
2525
import java.io.IOException;
26+
import java.nio.Buffer;
2627
import java.nio.ByteBuffer;
2728
import java.security.GeneralSecurityException;
2829
import java.util.logging.Level;
@@ -199,7 +200,7 @@ public ByteBuffer startServerHandshake(ByteBuffer inBytes) throws GeneralSecurit
199200
throw new GeneralSecurityException(e);
200201
}
201202
handleResponse(resp);
202-
inBytes.position(inBytes.position() + resp.getBytesConsumed());
203+
((Buffer) inBytes).position(inBytes.position() + resp.getBytesConsumed());
203204
return resp.getOutFrames().asReadOnlyByteBuffer();
204205
}
205206

@@ -227,7 +228,7 @@ public ByteBuffer next(ByteBuffer inBytes) throws GeneralSecurityException {
227228
throw new GeneralSecurityException(e);
228229
}
229230
handleResponse(resp);
230-
inBytes.position(inBytes.position() + resp.getBytesConsumed());
231+
((Buffer) inBytes).position(inBytes.position() + resp.getBytesConsumed());
231232
return resp.getOutFrames().asReadOnlyByteBuffer();
232233
}
233234

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.common.base.Preconditions;
2323
import io.grpc.alts.internal.HandshakerServiceGrpc.HandshakerServiceStub;
2424
import io.netty.buffer.ByteBufAllocator;
25+
import java.nio.Buffer;
2526
import java.nio.ByteBuffer;
2627
import java.security.GeneralSecurityException;
2728
import java.util.ArrayList;
@@ -151,10 +152,10 @@ public void getBytesToSendToPeer(ByteBuffer bytes) throws GeneralSecurityExcepti
151152
ByteBuffer outputFrameAlias = outputFrame;
152153
if (outputFrame.remaining() > bytes.remaining()) {
153154
outputFrameAlias = outputFrame.duplicate();
154-
outputFrameAlias.limit(outputFrameAlias.position() + bytes.remaining());
155+
((Buffer) outputFrameAlias).limit(outputFrameAlias.position() + bytes.remaining());
155156
}
156157
bytes.put(outputFrameAlias);
157-
outputFrame.position(outputFrameAlias.position());
158+
((Buffer) outputFrame).position(outputFrameAlias.position());
158159
}
159160

160161
/**

alts/src/test/java/io/grpc/alts/internal/AltsFramingTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static org.junit.Assert.fail;
2121

22+
import java.nio.Buffer;
2223
import java.nio.ByteBuffer;
2324
import java.nio.ByteOrder;
2425
import java.security.GeneralSecurityException;
@@ -38,7 +39,7 @@ public void parserFrameLengthNegativeFails() throws GeneralSecurityException {
3839
buffer.order(ByteOrder.LITTLE_ENDIAN);
3940
buffer.putInt(-1); // write invalid length
4041
buffer.put((byte) 0); // write some byte
41-
buffer.flip();
42+
((Buffer) buffer).flip();
4243

4344
try {
4445
parser.readBytes(buffer);
@@ -56,7 +57,7 @@ public void parserFrameLengthSmallerMessageTypeFails() throws GeneralSecurityExc
5657
buffer.order(ByteOrder.LITTLE_ENDIAN);
5758
buffer.putInt(AltsFraming.getFrameMessageTypeHeaderSize() - 1); // write invalid length
5859
buffer.put((byte) 0); // write some byte
59-
buffer.flip();
60+
((Buffer) buffer).flip();
6061

6162
try {
6263
parser.readBytes(buffer);
@@ -74,7 +75,7 @@ public void parserFrameLengthTooLargeFails() throws GeneralSecurityException {
7475
buffer.order(ByteOrder.LITTLE_ENDIAN);
7576
buffer.putInt(AltsFraming.getMaxDataLength() + 1); // write invalid length
7677
buffer.put((byte) 0); // write some byte
77-
buffer.flip();
78+
((Buffer) buffer).flip();
7879

7980
try {
8081
parser.readBytes(buffer);
@@ -97,7 +98,7 @@ public void parserFrameLengthMaxOk() throws GeneralSecurityException {
9798
buffer.putInt(6); // default message type
9899
buffer.put(new byte[dataLength - AltsFraming.getFrameMessageTypeHeaderSize()]); // write data
99100
buffer.put((byte) 0);
100-
buffer.flip();
101+
((Buffer) buffer).flip();
101102

102103
parser.readBytes(buffer);
103104

@@ -116,7 +117,7 @@ public void parserFrameLengthZeroOk() throws GeneralSecurityException {
116117
buffer.putInt(dataLength); // write invalid length
117118
buffer.putInt(6); // default message type
118119
buffer.put((byte) 0);
119-
buffer.flip();
120+
((Buffer) buffer).flip();
120121

121122
parser.readBytes(buffer);
122123

alts/src/test/java/io/grpc/alts/internal/AltsHandshakerClientTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import com.google.common.collect.ImmutableList;
3131
import com.google.protobuf.ByteString;
32+
import java.nio.Buffer;
3233
import java.nio.ByteBuffer;
3334
import java.security.GeneralSecurityException;
3435
import org.junit.Before;
@@ -178,7 +179,7 @@ public void startServerHandshakeWithPrefixBuffer() throws Exception {
178179
.thenReturn(MockAltsHandshakerResp.getOkResponse(BYTES_CONSUMED));
179180

180181
ByteBuffer inBytes = ByteBuffer.allocate(IN_BYTES_SIZE);
181-
inBytes.position(PREFIX_POSITION);
182+
((Buffer) inBytes).position(PREFIX_POSITION);
182183
ByteBuffer outFrame = handshaker.startServerHandshake(inBytes);
183184

184185
assertEquals(ByteString.copyFrom(outFrame), MockAltsHandshakerResp.getOutFrame());

alts/src/test/java/io/grpc/alts/internal/AltsTsiHandshakerTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static org.mockito.Mockito.when;
2727

2828
import com.google.protobuf.ByteString;
29+
import java.nio.Buffer;
2930
import java.nio.ByteBuffer;
3031
import org.junit.Before;
3132
import org.junit.Test;
@@ -112,7 +113,7 @@ public void processBytesFromPeerStartServer() throws Exception {
112113
verify(mockServer, never()).startClientHandshake();
113114
verify(mockServer, never()).next(ArgumentMatchers.<ByteBuffer>any());
114115
// Mock transport buffer all consumed by processBytesFromPeer and there is an output frame.
115-
transportBuffer.position(transportBuffer.limit());
116+
((Buffer) transportBuffer).position(transportBuffer.limit());
116117
when(mockServer.startServerHandshake(transportBuffer)).thenReturn(outputFrame);
117118
when(mockServer.isFinished()).thenReturn(false);
118119

@@ -127,7 +128,7 @@ public void processBytesFromPeerStartServerEmptyOutput() throws Exception {
127128
verify(mockServer, never()).next(ArgumentMatchers.<ByteBuffer>any());
128129
// Mock transport buffer all consumed by processBytesFromPeer and output frame is empty.
129130
// Expect processBytesFromPeer return False, because more data are needed from the peer.
130-
transportBuffer.position(transportBuffer.limit());
131+
((Buffer) transportBuffer).position(transportBuffer.limit());
131132
when(mockServer.startServerHandshake(transportBuffer)).thenReturn(emptyOutputFrame);
132133
when(mockServer.isFinished()).thenReturn(false);
133134

@@ -174,7 +175,7 @@ public void processBytesFromPeerClientNext() throws Exception {
174175
when(mockClient.isFinished()).thenReturn(false);
175176

176177
handshakerClient.getBytesToSendToPeer(transportBuffer);
177-
transportBuffer.position(transportBuffer.limit());
178+
((Buffer) transportBuffer).position(transportBuffer.limit());
178179
assertFalse(handshakerClient.processBytesFromPeer(transportBuffer));
179180
}
180181

0 commit comments

Comments
 (0)