Skip to content

Commit 06fff33

Browse files
committed
Merge remote-tracking branch 'origin/master' into ext-proc-client-flow-control
# Conflicts: # xds/src/test/java/io/grpc/xds/ExternalProcessorClientInterceptorTest.java
2 parents 33d2df9 + 21d6c71 commit 06fff33

128 files changed

Lines changed: 3289 additions & 300 deletions

File tree

Some content is hidden

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

‎MODULE.bazel‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module(
22
name = "grpc-java",
3-
version = "1.83.0-SNAPSHOT", # CURRENT_GRPC_VERSION
3+
version = "1.84.0-SNAPSHOT", # CURRENT_GRPC_VERSION
44
repo_name = "io_grpc_grpc_java",
55
)
66

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gRPC-Java - An RPC library and framework
2020
Supported Platforms
2121
-------------------
2222

23-
gRPC-Java supports Java 8 and later. Android minSdkVersion 23 (Marshmallow) and
23+
gRPC-Java supports Java 8 and later. Android minSdkVersion 24 (Nougat) and
2424
later are supported with [Java 8 language desugaring][android-java-8].
2525

2626
TLS usage on Android typically requires Play Services Dynamic Security Provider.

‎android/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ android {
1414
}
1515
compileSdkVersion 34
1616
defaultConfig {
17-
minSdkVersion 23
17+
minSdkVersion 24
1818
targetSdkVersion 33
1919
versionCode 1
2020
versionName "1.0"

‎android/src/main/java/io/grpc/android/AndroidChannelBuilder.java‎

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

1717
package io.grpc.android;
1818

19-
import android.annotation.TargetApi;
2019
import android.content.BroadcastReceiver;
2120
import android.content.Context;
2221
import android.content.Intent;
2322
import android.content.IntentFilter;
2423
import android.net.ConnectivityManager;
2524
import android.net.Network;
26-
import android.os.Build;
2725
import android.util.Log;
2826
import com.google.common.annotations.VisibleForTesting;
2927
import com.google.common.base.Preconditions;
@@ -212,7 +210,7 @@ static final class AndroidChannel extends ManagedChannel {
212210
private void configureNetworkMonitoring() {
213211
// Android N added the registerDefaultNetworkCallback API to listen to changes in the device's
214212
// default network. For earlier Android API levels, use the BroadcastReceiver API.
215-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && connectivityManager != null) {
213+
if (connectivityManager != null) {
216214
final DefaultNetworkCallback defaultNetworkCallback = new DefaultNetworkCallback();
217215
connectivityManager.registerDefaultNetworkCallback(defaultNetworkCallback);
218216
unregisterRunnable =
@@ -306,7 +304,6 @@ public void enterIdle() {
306304
}
307305

308306
/** Respond to changes in the default network. Only used on API levels 24+. */
309-
@TargetApi(Build.VERSION_CODES.N)
310307
private class DefaultNetworkCallback extends ConnectivityManager.NetworkCallback {
311308
@Override
312309
public void onAvailable(Network network) {

‎android/src/test/java/io/grpc/android/AndroidChannelBuilderTest.java‎

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
2525

2626
import android.content.Context;
27-
import android.content.Intent;
2827
import android.net.ConnectivityManager;
2928
import android.net.Network;
3029
import androidx.test.core.app.ApplicationProvider;
@@ -105,22 +104,6 @@ public void usingBuilderConstructor() {
105104
assertThat(androidBuilder.delegate()).isSameInstanceAs(wrappedBuilder);
106105
}
107106

108-
@Test
109-
@Config(sdk = 23)
110-
public void nullContextDoesNotThrow_api23() {
111-
TestChannel delegateChannel = new TestChannel();
112-
ManagedChannel androidChannel = new AndroidChannelBuilder.AndroidChannel(delegateChannel, null);
113-
114-
// Network change and shutdown should be no-op for the channel without an Android Context
115-
shadowOf(connectivityManager).setActiveNetworkInfo(WIFI_CONNECTED);
116-
ApplicationProvider
117-
.getApplicationContext()
118-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
119-
androidChannel.shutdown();
120-
121-
assertThat(delegateChannel.enterIdleCount).isEqualTo(0);
122-
}
123-
124107
@Test
125108
@Config(sdk = 24)
126109
public void nullContextDoesNotThrow_api24() {
@@ -135,59 +118,6 @@ public void nullContextDoesNotThrow_api24() {
135118
assertThat(delegateChannel.enterIdleCount).isEqualTo(0);
136119
}
137120

138-
@Test
139-
@Config(sdk = 23)
140-
public void networkChanges_api23() {
141-
TestChannel delegateChannel = new TestChannel();
142-
ManagedChannel androidChannel =
143-
new AndroidChannelBuilder.AndroidChannel(
144-
delegateChannel, ApplicationProvider.getApplicationContext());
145-
assertThat(delegateChannel.enterIdleCount).isEqualTo(0);
146-
147-
// On API levels < 24, the broadcast receiver will invoke enterIdle() on the first
148-
// connectivity action broadcast regardless of previous connection status
149-
shadowOf(connectivityManager).setActiveNetworkInfo(WIFI_CONNECTED);
150-
ApplicationProvider
151-
.getApplicationContext()
152-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
153-
assertThat(delegateChannel.enterIdleCount).isEqualTo(1);
154-
155-
// Drop the connection
156-
shadowOf(connectivityManager).setActiveNetworkInfo(null);
157-
ApplicationProvider
158-
.getApplicationContext()
159-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
160-
assertThat(delegateChannel.enterIdleCount).isEqualTo(1);
161-
162-
// Notify that a new but not connected network is available
163-
shadowOf(connectivityManager).setActiveNetworkInfo(MOBILE_DISCONNECTED);
164-
ApplicationProvider
165-
.getApplicationContext()
166-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
167-
assertThat(delegateChannel.enterIdleCount).isEqualTo(1);
168-
169-
// Establish a connection
170-
shadowOf(connectivityManager).setActiveNetworkInfo(MOBILE_CONNECTED);
171-
ApplicationProvider
172-
.getApplicationContext()
173-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
174-
assertThat(delegateChannel.enterIdleCount).isEqualTo(2);
175-
176-
// Disconnect, then shutdown the channel and verify that the broadcast receiver has been
177-
// unregistered
178-
shadowOf(connectivityManager).setActiveNetworkInfo(null);
179-
ApplicationProvider
180-
.getApplicationContext()
181-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
182-
androidChannel.shutdown();
183-
shadowOf(connectivityManager).setActiveNetworkInfo(MOBILE_CONNECTED);
184-
ApplicationProvider
185-
.getApplicationContext()
186-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
187-
188-
assertThat(delegateChannel.enterIdleCount).isEqualTo(2);
189-
}
190-
191121
@Test
192122
@Config(sdk = 24)
193123
public void networkChanges_api24() {
@@ -223,27 +153,6 @@ public void networkChanges_api24() {
223153
assertThat(delegateChannel.enterIdleCount).isEqualTo(3);
224154
}
225155

226-
@Test
227-
@Config(sdk = 23)
228-
public void shutdownNowUnregistersBroadcastReceiver_api23() {
229-
TestChannel delegateChannel = new TestChannel();
230-
ManagedChannel androidChannel =
231-
new AndroidChannelBuilder.AndroidChannel(
232-
delegateChannel, ApplicationProvider.getApplicationContext());
233-
234-
shadowOf(connectivityManager).setActiveNetworkInfo(null);
235-
ApplicationProvider
236-
.getApplicationContext()
237-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
238-
androidChannel.shutdownNow();
239-
shadowOf(connectivityManager).setActiveNetworkInfo(WIFI_CONNECTED);
240-
ApplicationProvider
241-
.getApplicationContext()
242-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
243-
244-
assertThat(delegateChannel.enterIdleCount).isEqualTo(0);
245-
}
246-
247156
@Test
248157
@Config(sdk = 24)
249158
public void shutdownNowUnregistersNetworkCallback_api24() {
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2026 The gRPC Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.grpc;
18+
19+
20+
21+
/**
22+
* A configurator for child channels created by gRPC's internal infrastructure.
23+
*
24+
* <p>This interface allows users to inject configuration (such as credentials, interceptors,
25+
* or flow control settings) into channels created automatically by gRPC for control plane
26+
* operations. Common use cases include:
27+
* <ul>
28+
* <li>xDS control plane connections</li>
29+
* <li>Load Balancing helper channels (OOB channels)</li>
30+
* </ul>
31+
*
32+
* <p><strong>Usage Example:</strong>
33+
* <pre>{@code
34+
* // 1. Define the configurator
35+
* ChannelConfigurator configurator = builder -> {
36+
* builder.maxInboundMessageSize(4 * 1024 * 1024);
37+
* };
38+
*
39+
* // 2. Apply to parent channel - automatically used for ALL child channels
40+
* ManagedChannel channel = ManagedChannelBuilder
41+
* .forTarget("xds:///my-service")
42+
* .childChannelConfigurator(configurator)
43+
* .build();
44+
* }</pre>
45+
*
46+
* <p>Implementations must be thread-safe as the configure methods may be invoked concurrently
47+
* by multiple internal components.
48+
*
49+
* @since 1.83.0
50+
*/
51+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/12574")
52+
@FunctionalInterface
53+
public interface ChannelConfigurator {
54+
55+
/**
56+
* Configures a builder for a new child channel.
57+
*
58+
* <p>This method is invoked synchronously during the creation of the child channel,
59+
* before {@link ManagedChannelBuilder#build()} is called.
60+
*
61+
* <p><strong>Note:</strong> Implementations must only apply configurations to the
62+
* provided builder and must NOT call {@code builder.build()} themselves.
63+
*
64+
* <p><strong>Note:</strong> The provided {@code builder} is generic ({@code ?}). Implementations
65+
* should use universal configuration methods (like {@code intercept()}, {@code userAgent()})
66+
* on the builder rather than casting it to specific implementation types.
67+
*
68+
* @param builder the mutable channel builder for the new child channel
69+
*/
70+
void configureChannelBuilder(ManagedChannelBuilder<?> builder);
71+
}

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,45 @@ public void streamCreated(@Grpc.TransportAttr Attributes transportAttrs, Metadat
5757
public void createPendingStream() {
5858
}
5959

60+
/**
61+
* Called when an attempt-level delay segment (such as waiting for a load balancing pick or
62+
* connection establishment) starts.
63+
*
64+
* <p>This method is invoked synchronously on the attempt thread. Implementations should start
65+
* internal timers or child tracing spans (named strictly {@code "Attempt Delay"}) carrying the
66+
* canonical {@code grpc.delay_type} attribute.
67+
*
68+
* @param delayType canonical low-cardinality label categorizing the delay (e.g., "connecting")
69+
* @param delayReason high-cardinality diagnostic string describing granular runtime conditions
70+
* @since 1.82.0
71+
*/
72+
public void recordAttemptDelayStart(String delayType, String delayReason) {
73+
}
74+
75+
/**
76+
* Called when an attempt-level delay reason changes while the overall delay type remains
77+
* constant (for example, when a priority load balancing policy fails over between tiers).
78+
*
79+
* <p>Implementations should record structured events (such as {@code "Delay state transition"})
80+
* on the active delay span without recreating the span or resetting cumulative timers.
81+
*
82+
* @param delayReason updated high-cardinality diagnostic string describing new conditions
83+
* @since 1.82.0
84+
*/
85+
public void recordAttemptDelayReasonChanged(String delayReason) {
86+
}
87+
88+
/**
89+
* Called when an attempt-level delay segment ends upon successful pick or stream creation.
90+
*
91+
* <p>Implementations should simultaneously close active child tracing spans and record elapsed
92+
* duration to the {@code grpc.client.attempt.delay.duration} histogram.
93+
*
94+
* @since 1.82.0
95+
*/
96+
public void recordAttemptDelayEnd() {
97+
}
98+
6099
/**
61100
* Headers has been sent to the socket.
62101
*/

‎api/src/main/java/io/grpc/ForwardingChannelBuilder.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ public T disableServiceConfigLookUp() {
242242
return thisT();
243243
}
244244

245+
246+
@Override
247+
public T childChannelConfigurator(ChannelConfigurator channelConfigurator) {
248+
delegate().childChannelConfigurator(channelConfigurator);
249+
return thisT();
250+
}
251+
245252
/**
246253
* Returns the correctly typed version of the builder.
247254
*/

‎api/src/main/java/io/grpc/ForwardingChannelBuilder2.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ public <X> T setNameResolverArg(NameResolver.Args.Key<X> key, X value) {
269269
return thisT();
270270
}
271271

272+
273+
@Override
274+
public T childChannelConfigurator(ChannelConfigurator channelConfigurator) {
275+
delegate().childChannelConfigurator(channelConfigurator);
276+
return thisT();
277+
}
278+
272279
/**
273280
* Returns the {@link ManagedChannel} built by the delegate by default. Overriding method can
274281
* return different value.

0 commit comments

Comments
 (0)