Skip to content

Commit 59fe14e

Browse files
Merge branch 'master' into sni-san-changes
2 parents 30cea9a + 9ade38a commit 59fe14e

File tree

23 files changed

+628
-68
lines changed

23 files changed

+628
-68
lines changed

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ public static final class StreamInfo {
132132
private final CallOptions callOptions;
133133
private final int previousAttempts;
134134
private final boolean isTransparentRetry;
135+
private final boolean isHedging;
135136

136137
StreamInfo(
137-
CallOptions callOptions, int previousAttempts, boolean isTransparentRetry) {
138+
CallOptions callOptions, int previousAttempts, boolean isTransparentRetry,
139+
boolean isHedging) {
138140
this.callOptions = checkNotNull(callOptions, "callOptions");
139141
this.previousAttempts = previousAttempts;
140142
this.isTransparentRetry = isTransparentRetry;
143+
this.isHedging = isHedging;
141144
}
142145

143146
/**
@@ -165,6 +168,15 @@ public boolean isTransparentRetry() {
165168
return isTransparentRetry;
166169
}
167170

171+
/**
172+
* Whether the stream is hedging.
173+
*
174+
* @since 1.74.0
175+
*/
176+
public boolean isHedging() {
177+
return isHedging;
178+
}
179+
168180
/**
169181
* Converts this StreamInfo into a new Builder.
170182
*
@@ -174,7 +186,9 @@ public Builder toBuilder() {
174186
return new Builder()
175187
.setCallOptions(callOptions)
176188
.setPreviousAttempts(previousAttempts)
177-
.setIsTransparentRetry(isTransparentRetry);
189+
.setIsTransparentRetry(isTransparentRetry)
190+
.setIsHedging(isHedging);
191+
178192
}
179193

180194
/**
@@ -192,6 +206,7 @@ public String toString() {
192206
.add("callOptions", callOptions)
193207
.add("previousAttempts", previousAttempts)
194208
.add("isTransparentRetry", isTransparentRetry)
209+
.add("isHedging", isHedging)
195210
.toString();
196211
}
197212

@@ -204,6 +219,7 @@ public static final class Builder {
204219
private CallOptions callOptions = CallOptions.DEFAULT;
205220
private int previousAttempts;
206221
private boolean isTransparentRetry;
222+
private boolean isHedging;
207223

208224
Builder() {
209225
}
@@ -236,11 +252,21 @@ public Builder setIsTransparentRetry(boolean isTransparentRetry) {
236252
return this;
237253
}
238254

255+
/**
256+
* Sets whether the stream is hedging.
257+
*
258+
* @since 1.74.0
259+
*/
260+
public Builder setIsHedging(boolean isHedging) {
261+
this.isHedging = isHedging;
262+
return this;
263+
}
264+
239265
/**
240266
* Builds a new StreamInfo.
241267
*/
242268
public StreamInfo build() {
243-
return new StreamInfo(callOptions, previousAttempts, isTransparentRetry);
269+
return new StreamInfo(callOptions, previousAttempts, isTransparentRetry, isHedging);
244270
}
245271
}
246272
}

build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,25 @@ subprojects {
197197
}
198198
}
199199

200+
plugins.withId("com.android.base") {
201+
android {
202+
lint {
203+
abortOnError true
204+
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
205+
warningsAsErrors true
206+
}
207+
}
208+
}
209+
tasks.withType(JavaCompile).configureEach {
210+
it.options.compilerArgs += [
211+
"-Xlint:all"
212+
]
213+
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
214+
it.options.compilerArgs += ["-Werror"]
215+
}
216+
}
217+
}
218+
200219
plugins.withId("java") {
201220
dependencies {
202221
testImplementation libraries.junit,

buildscripts/kokoro/windows32.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cd "%WORKSPACE%"
2525

2626
SET TARGET_ARCH=x86_32
2727
SET FAIL_ON_WARNINGS=true
28-
SET PROTOBUF_VER=22.5
28+
SET PROTOBUF_VER=26.1
2929
SET PKG_CONFIG_PATH=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib\\pkgconfig
3030
SET VC_PROTOBUF_LIBS=/LIBPATH:%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib
3131
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\include

buildscripts/kokoro/windows64.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cd "%WORKSPACE%"
2424

2525
SET TARGET_ARCH=x86_64
2626
SET FAIL_ON_WARNINGS=true
27-
SET PROTOBUF_VER=22.5
27+
SET PROTOBUF_VER=26.1
2828
SET PKG_CONFIG_PATH=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib\\pkgconfig
2929
SET VC_PROTOBUF_LIBS=/LIBPATH:%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib
3030
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\include

buildscripts/make_dependencies.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
choco install -y pkgconfiglite
22
choco install -y openjdk --version=17.0
33
set PATH=%PATH%;"c:\Program Files\OpenJDK\jdk-17\bin"
4-
set PROTOBUF_VER=22.5
5-
set ABSL_VERSION=20230125.4
4+
set PROTOBUF_VER=26.1
5+
set ABSL_VERSION=20250127.1
66
set CMAKE_NAME=cmake-3.26.3-windows-x86_64
77

88
if not exist "protobuf-%PROTOBUF_VER%\build\Release\" (
@@ -51,7 +51,7 @@ for /f "tokens=4 delims=\" %%a in ("%VCINSTALLDIR%") do (
5151
for /f "tokens=1 delims=." %%a in ("%VisualStudioVersion%") do (
5252
SET visual_studio_major_version=%%a
5353
)
54-
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=%cd%\protobuf-%PROTOBUF_VER% -DCMAKE_PREFIX_PATH=%cd%\protobuf-%PROTOBUF_VER% -G "Visual Studio %visual_studio_major_version% %VC_YEAR%" %CMAKE_VSARCH% .. || exit /b 1
54+
cmake -DABSL_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=%cd%\protobuf-%PROTOBUF_VER% -DCMAKE_PREFIX_PATH=%cd%\protobuf-%PROTOBUF_VER% -G "Visual Studio %visual_studio_major_version% %VC_YEAR%" %CMAKE_VSARCH% .. || exit /b 1
5555
cmake --build . --config Release --target install || exit /b 1
5656
popd
5757
goto :eof

buildscripts/make_dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Build protoc
44
set -evux -o pipefail
55

6-
PROTOBUF_VERSION=22.5
7-
ABSL_VERSION=20230125.4
6+
PROTOBUF_VERSION=26.1
7+
ABSL_VERSION=20250127.1
88
CMAKE_VERSION=3.26.3
99

1010
# ARCH is x86_64 bit unless otherwise specified.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ public void runInContext() {
250250
stream = clientStreamProvider.newStream(method, callOptions, headers, context);
251251
} else {
252252
ClientStreamTracer[] tracers =
253-
GrpcUtil.getClientStreamTracers(callOptions, headers, 0, false);
253+
GrpcUtil.getClientStreamTracers(callOptions, headers, 0,
254+
false, false);
254255
String deadlineName = contextIsDeadlineSource ? "Context" : "CallOptions";
255256
Long nameResolutionDelay = callOptions.getOption(NAME_RESOLUTION_DELAYED);
256257
String description = String.format(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,15 @@ public ListenableFuture<SocketStats> getStats() {
759759

760760
/** Gets stream tracers based on CallOptions. */
761761
public static ClientStreamTracer[] getClientStreamTracers(
762-
CallOptions callOptions, Metadata headers, int previousAttempts, boolean isTransparentRetry) {
762+
CallOptions callOptions, Metadata headers, int previousAttempts, boolean isTransparentRetry,
763+
boolean isHedging) {
763764
List<ClientStreamTracer.Factory> factories = callOptions.getStreamTracerFactories();
764765
ClientStreamTracer[] tracers = new ClientStreamTracer[factories.size() + 1];
765766
StreamInfo streamInfo = StreamInfo.newBuilder()
766767
.setCallOptions(callOptions)
767768
.setPreviousAttempts(previousAttempts)
768769
.setIsTransparentRetry(isTransparentRetry)
770+
.setIsHedging(isHedging)
769771
.build();
770772
for (int i = 0; i < factories.size(); i++) {
771773
tracers[i] = factories.get(i).newClientStreamTracer(streamInfo, headers);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ public ClientStream newStream(
479479
// the delayed transport or a real transport will go in-use and cancel the idle timer.
480480
if (!retryEnabled) {
481481
ClientStreamTracer[] tracers = GrpcUtil.getClientStreamTracers(
482-
callOptions, headers, 0, /* isTransparentRetry= */ false);
482+
callOptions, headers, 0, /* isTransparentRetry= */ false,
483+
/* isHedging= */false);
483484
Context origContext = context.attach();
484485
try {
485486
return delayedTransport.newStream(method, headers, callOptions, tracers);
@@ -519,10 +520,10 @@ void postCommit() {
519520
@Override
520521
ClientStream newSubstream(
521522
Metadata newHeaders, ClientStreamTracer.Factory factory, int previousAttempts,
522-
boolean isTransparentRetry) {
523+
boolean isTransparentRetry, boolean isHedgedStream) {
523524
CallOptions newOptions = callOptions.withStreamTracerFactory(factory);
524525
ClientStreamTracer[] tracers = GrpcUtil.getClientStreamTracers(
525-
newOptions, newHeaders, previousAttempts, isTransparentRetry);
526+
newOptions, newHeaders, previousAttempts, isTransparentRetry, isHedgedStream);
526527
Context origContext = context.attach();
527528
try {
528529
return delayedTransport.newStream(method, newHeaders, newOptions, tracers);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ final class OobChannel extends ManagedChannel implements InternalInstrumented<Ch
8888
public ClientStream newStream(MethodDescriptor<?, ?> method,
8989
CallOptions callOptions, Metadata headers, Context context) {
9090
ClientStreamTracer[] tracers = GrpcUtil.getClientStreamTracers(
91-
callOptions, headers, 0, /* isTransparentRetry= */ false);
91+
callOptions, headers, 0, /* isTransparentRetry= */ false,
92+
/* isHedging= */ false);
9293
Context origContext = context.attach();
9394
// delayed transport's newStream() always acquires a lock, but concurrent performance doesn't
9495
// matter here because OOB communication should be sparse, and it's not on application RPC's

0 commit comments

Comments
 (0)