Skip to content

Commit 08391fb

Browse files
committed
Merge branch 'master' into systemrootcerts-ignore-trusted-root-updates
2 parents 3845e16 + 9cddcb4 commit 08391fb

File tree

91 files changed

+2084
-1605
lines changed

Some content is hidden

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

91 files changed

+2084
-1605
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.76.0-SNAPSHOT", # CURRENT_GRPC_VERSION
5+
version = "1.77.0-SNAPSHOT", # CURRENT_GRPC_VERSION
66
)
77

88
# GRPC_DEPS_START

SECURITY.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,10 @@ is an option](#tls-with-conscrypt). Otherwise you need to [build your own 32-bit
330330
version of
331331
`netty-tcnative`](https://netty.io/wiki/forked-tomcat-native.html#wiki-h2-6).
332332

333-
If on Alpine Linux and you see "Error loading shared library libcrypt.so.1: No
334-
such file or directory". Run `apk update && apk add libc6-compat` to install the
335-
necessary dependency.
336-
337-
If on Alpine Linux, try to use `grpc-netty-shaded` instead of `grpc-netty` or
338-
(if you need `grpc-netty`) `netty-tcnative-boringssl-static` instead of
339-
`netty-tcnative`. If those are not an option, you may consider using
340-
[netty-tcnative-alpine](https://github.com/pires/netty-tcnative-alpine).
333+
If on Alpine Linux, depending on your specific JDK you may see a crash in
334+
netty_tcnative. This is generally caused by a missing symbol. Run `apk install
335+
gcompat` and use the environment variable `LD_PRELOAD=/lib/libgcompat.so.0` when
336+
executing Java.
341337

342338
If on Fedora 30 or later and you see "libcrypt.so.1: cannot open shared object
343339
file: No such file or directory". Run `dnf -y install libxcrypt-compat` to

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,15 @@ public void onBlockedStatusChanged(Network network, boolean blocked) {
323323

324324
/** Respond to network changes. Only used on API levels < 24. */
325325
private class NetworkReceiver extends BroadcastReceiver {
326-
private boolean isConnected = false;
327326

328327
@SuppressWarnings("deprecation")
329328
@Override
330329
public void onReceive(Context context, Intent intent) {
331330
ConnectivityManager conn =
332331
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
333332
android.net.NetworkInfo networkInfo = conn.getActiveNetworkInfo();
334-
boolean wasConnected = isConnected;
335-
isConnected = networkInfo != null && networkInfo.isConnected();
336-
if (isConnected && !wasConnected) {
333+
334+
if (networkInfo != null && networkInfo.isConnected()) {
337335
delegate.enterIdle();
338336
}
339337
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@ public void networkChanges_api23() {
152152
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
153153
assertThat(delegateChannel.enterIdleCount).isEqualTo(1);
154154

155-
// The broadcast receiver may fire when the active network status has not actually changed
156-
ApplicationProvider
157-
.getApplicationContext()
158-
.sendBroadcast(new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
159-
assertThat(delegateChannel.enterIdleCount).isEqualTo(1);
160-
161155
// Drop the connection
162156
shadowOf(connectivityManager).setActiveNetworkInfo(null);
163157
ApplicationProvider

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public final class EquivalentAddressGroup {
5050
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/6138")
5151
public static final Attributes.Key<String> ATTR_AUTHORITY_OVERRIDE =
5252
Attributes.Key.create("io.grpc.EquivalentAddressGroup.ATTR_AUTHORITY_OVERRIDE");
53+
/**
54+
* The name of the locality that this EquivalentAddressGroup is in.
55+
*/
56+
public static final Attributes.Key<String> ATTR_LOCALITY_NAME =
57+
Attributes.Key.create("io.grpc.EquivalentAddressGroup.LOCALITY");
5358
private final List<SocketAddress> addrs;
5459
private final Attributes attrs;
5560

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,11 @@ public String toString() {
855855
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
856856
public static final class Builder {
857857

858+
private static final Object[][] EMPTY_CUSTOM_OPTIONS = new Object[0][2];
859+
858860
private List<EquivalentAddressGroup> addrs;
859861
private Attributes attrs = Attributes.EMPTY;
860-
private Object[][] customOptions = new Object[0][2];
862+
private Object[][] customOptions = EMPTY_CUSTOM_OPTIONS;
861863

862864
Builder() {
863865
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2025 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+
import java.util.List;
20+
21+
/**
22+
* Represents a long-valued up down counter metric instrument.
23+
*/
24+
@Internal
25+
public final class LongUpDownCounterMetricInstrument extends PartialMetricInstrument {
26+
public LongUpDownCounterMetricInstrument(int index, String name, String description, String unit,
27+
List<String> requiredLabelKeys,
28+
List<String> optionalLabelKeys,
29+
boolean enableByDefault) {
30+
super(index, name, description, unit, requiredLabelKeys, optionalLabelKeys, enableByDefault);
31+
}
32+
}

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,47 @@ public LongCounterMetricInstrument registerLongCounter(String name,
144144
}
145145
}
146146

147+
/**
148+
* Registers a new Long Up Down Counter metric instrument.
149+
*
150+
* @param name the name of the metric
151+
* @param description a description of the metric
152+
* @param unit the unit of measurement for the metric
153+
* @param requiredLabelKeys a list of required label keys
154+
* @param optionalLabelKeys a list of optional label keys
155+
* @param enableByDefault whether the metric should be enabled by default
156+
* @return the newly created LongUpDownCounterMetricInstrument
157+
* @throws IllegalStateException if a metric with the same name already exists
158+
*/
159+
public LongUpDownCounterMetricInstrument registerLongUpDownCounter(String name,
160+
String description,
161+
String unit,
162+
List<String> requiredLabelKeys,
163+
List<String> optionalLabelKeys,
164+
boolean enableByDefault) {
165+
checkArgument(!Strings.isNullOrEmpty(name), "missing metric name");
166+
checkNotNull(description, "description");
167+
checkNotNull(unit, "unit");
168+
checkNotNull(requiredLabelKeys, "requiredLabelKeys");
169+
checkNotNull(optionalLabelKeys, "optionalLabelKeys");
170+
synchronized (lock) {
171+
if (registeredMetricNames.contains(name)) {
172+
throw new IllegalStateException("Metric with name " + name + " already exists");
173+
}
174+
int index = nextAvailableMetricIndex;
175+
if (index + 1 == metricInstruments.length) {
176+
resizeMetricInstruments();
177+
}
178+
LongUpDownCounterMetricInstrument instrument = new LongUpDownCounterMetricInstrument(
179+
index, name, description, unit, requiredLabelKeys, optionalLabelKeys,
180+
enableByDefault);
181+
metricInstruments[index] = instrument;
182+
registeredMetricNames.add(name);
183+
nextAvailableMetricIndex += 1;
184+
return instrument;
185+
}
186+
}
187+
147188
/**
148189
* Registers a new Double Histogram metric instrument.
149190
*

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ default void addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, do
5050
* Adds a value for a long valued counter metric instrument.
5151
*
5252
* @param metricInstrument The counter metric instrument to add the value against.
53-
* @param value The value to add.
53+
* @param value The value to add. MUST be non-negative.
5454
* @param requiredLabelValues A list of required label values for the metric.
5555
* @param optionalLabelValues A list of additional, optional label values for the metric.
5656
*/
@@ -66,6 +66,29 @@ default void addLongCounter(LongCounterMetricInstrument metricInstrument, long v
6666
metricInstrument.getOptionalLabelKeys().size());
6767
}
6868

69+
/**
70+
* Adds a value for a long valued up down counter metric instrument.
71+
*
72+
* @param metricInstrument The counter metric instrument to add the value against.
73+
* @param value The value to add. May be positive, negative or zero.
74+
* @param requiredLabelValues A list of required label values for the metric.
75+
* @param optionalLabelValues A list of additional, optional label values for the metric.
76+
*/
77+
default void addLongUpDownCounter(LongUpDownCounterMetricInstrument metricInstrument,
78+
long value,
79+
List<String> requiredLabelValues,
80+
List<String> optionalLabelValues) {
81+
checkArgument(requiredLabelValues != null
82+
&& requiredLabelValues.size() == metricInstrument.getRequiredLabelKeys().size(),
83+
"Incorrect number of required labels provided. Expected: %s",
84+
metricInstrument.getRequiredLabelKeys().size());
85+
checkArgument(optionalLabelValues != null
86+
&& optionalLabelValues.size() == metricInstrument.getOptionalLabelKeys().size(),
87+
"Incorrect number of optional labels provided. Expected: %s",
88+
metricInstrument.getOptionalLabelKeys().size());
89+
}
90+
91+
6992
/**
7093
* Records a value for a double-precision histogram metric instrument.
7194
*

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,26 @@ default void addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, do
6565
* Adds a value for a long valued counter metric associated with specified metric instrument.
6666
*
6767
* @param metricInstrument The counter metric instrument identifies metric measure to add.
68-
* @param value The value to record.
68+
* @param value The value to record. MUST be non-negative.
6969
* @param requiredLabelValues A list of required label values for the metric.
7070
* @param optionalLabelValues A list of additional, optional label values for the metric.
7171
*/
7272
default void addLongCounter(LongCounterMetricInstrument metricInstrument, long value,
73-
List<String> requiredLabelValues, List<String> optionalLabelValues) {
73+
List<String> requiredLabelValues, List<String> optionalLabelValues) {
74+
}
75+
76+
/**
77+
* Adds a value for a long valued up down counter metric associated with specified metric
78+
* instrument.
79+
*
80+
* @param metricInstrument The counter metric instrument identifies metric measure to add.
81+
* @param value The value to record. May be positive, negative or zero.
82+
* @param requiredLabelValues A list of required label values for the metric.
83+
* @param optionalLabelValues A list of additional, optional label values for the metric.
84+
*/
85+
default void addLongUpDownCounter(LongUpDownCounterMetricInstrument metricInstrument, long value,
86+
List<String> requiredLabelValues,
87+
List<String> optionalLabelValues) {
7488
}
7589

7690
/**

0 commit comments

Comments
 (0)