Skip to content

Commit 22631e3

Browse files
committed
Merge remote-tracking branch 'upstream/master' into ext-proc
# Conflicts: # xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java
2 parents a5c95a6 + 3db3235 commit 22631e3

80 files changed

Lines changed: 2568 additions & 537 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.

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
2+
3+
common:skip_android --deleted_packages=android,binder

.github/workflows/testing.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ jobs:
8080
strategy:
8181
matrix:
8282
bzlmod: [true, false]
83+
bazel_version: [8.7.0, 9.1.0]
84+
exclude:
85+
- bazel_version: 9.1.0
86+
bzlmod: false
8387
env:
84-
USE_BAZEL_VERSION: 7.7.1
88+
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
8589

8690
steps:
8791
- uses: actions/checkout@v4
@@ -100,11 +104,11 @@ jobs:
100104
key: ${{ runner.os }}-bazel-${{ env.USE_BAZEL_VERSION }}-${{ hashFiles('WORKSPACE', 'repositories.bzl') }}
101105

102106
- name: Run bazel build
103-
run: bazelisk build //... --enable_bzlmod=${{ matrix.bzlmod }}
107+
run: bazelisk build //... --config=skip_android --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}
104108

105109
- name: Run bazel test
106-
run: bazelisk test //... --enable_bzlmod=${{ matrix.bzlmod }}
110+
run: bazelisk test //... --config=skip_android --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}
107111

108112
- name: Run example bazel build
109-
run: bazelisk build //... --enable_bzlmod=${{ matrix.bzlmod }}
113+
run: bazelisk build //... --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}
110114
working-directory: ./examples

COMPILING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,26 @@ $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses
150150

151151
# Add 'export ANDROID_HOME=$HOME/Android/Sdk' to your .bashrc or equivalent
152152
```
153+
154+
Building with Bazel
155+
===================
156+
157+
grpc-java can also be built using [Bazel](https://bazel.build/). We support
158+
the two most recent major versions of Bazel.
159+
[Install bazelisk](https://github.com/bazelbuild/bazelisk#installation)
160+
to ensure you're always building using the latest supported version, then try:
161+
162+
```
163+
$ bazelisk build //...
164+
```
165+
166+
Some parts of grpc-java depend on Android. Bazel can build these parts too but,
167+
for size, licensing and maintenance reasons, it requires a locally installed
168+
Android SDK. If you don't have the SDK and/or don't care about Android, use the
169+
`skip_android` configuration to skip building the Android parts:
170+
171+
```sh
172+
$ bazelisk build //... --config=skip_android
173+
```
174+
175+
You cannot run the tests from Bazel at this time.

MODULE.bazel

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module(
22
name = "grpc-java",
33
version = "1.82.0-SNAPSHOT", # CURRENT_GRPC_VERSION
4-
compatibility_level = 0,
54
repo_name = "io_grpc_grpc_java",
65
)
76

@@ -21,22 +20,25 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
2120
"com.google.re2j:re2j:1.8",
2221
"com.google.s2a.proto.v2:s2a-proto:0.1.3",
2322
"com.google.truth:truth:1.4.5",
23+
"dev.cel:runtime:0.12.0",
24+
"dev.cel:protobuf:0.12.0",
25+
"dev.cel:common:0.12.0",
2426
"com.squareup.okhttp:okhttp:2.7.5",
2527
"com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day
26-
"io.netty:netty-buffer:4.1.132.Final",
27-
"io.netty:netty-codec-http2:4.1.132.Final",
28-
"io.netty:netty-codec-http:4.1.132.Final",
29-
"io.netty:netty-codec-socks:4.1.132.Final",
30-
"io.netty:netty-codec:4.1.132.Final",
31-
"io.netty:netty-common:4.1.132.Final",
32-
"io.netty:netty-handler-proxy:4.1.132.Final",
33-
"io.netty:netty-handler:4.1.132.Final",
34-
"io.netty:netty-resolver:4.1.132.Final",
28+
"io.netty:netty-buffer:4.1.133.Final",
29+
"io.netty:netty-codec-http2:4.1.133.Final",
30+
"io.netty:netty-codec-http:4.1.133.Final",
31+
"io.netty:netty-codec-socks:4.1.133.Final",
32+
"io.netty:netty-codec:4.1.133.Final",
33+
"io.netty:netty-common:4.1.133.Final",
34+
"io.netty:netty-handler-proxy:4.1.133.Final",
35+
"io.netty:netty-handler:4.1.133.Final",
36+
"io.netty:netty-resolver:4.1.133.Final",
3537
"io.netty:netty-tcnative-boringssl-static:2.0.75.Final",
3638
"io.netty:netty-tcnative-classes:2.0.75.Final",
37-
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.132.Final",
38-
"io.netty:netty-transport-native-unix-common:4.1.132.Final",
39-
"io.netty:netty-transport:4.1.132.Final",
39+
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.133.Final",
40+
"io.netty:netty-transport-native-unix-common:4.1.133.Final",
41+
"io.netty:netty-transport:4.1.133.Final",
4042
"io.opencensus:opencensus-api:0.31.0",
4143
"io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
4244
"io.perfmark:perfmark-api:0.27.0",
@@ -50,13 +52,21 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
5052
bazel_dep(name = "abseil-cpp", version = "20250512.1")
5153
bazel_dep(name = "bazel_jar_jar", version = "0.1.11.bcr.1")
5254
bazel_dep(name = "bazel_skylib", version = "1.7.1")
53-
bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5", repo_name = "com_google_googleapis")
55+
bazel_dep(name = "googleapis", version = "0.0.0-20260514-1dbb1a14", repo_name = "com_google_googleapis")
5456
bazel_dep(name = "grpc-proto", version = "0.0.0-20240627-ec30f58.bcr.1", repo_name = "io_grpc_grpc_proto")
5557
bazel_dep(name = "protobuf", version = "33.4", repo_name = "com_google_protobuf")
58+
bazel_dep(name = "rules_android", version = "0.7.2")
5659
bazel_dep(name = "rules_cc", version = "0.0.9")
5760
bazel_dep(name = "rules_java", version = "9.1.0")
5861
bazel_dep(name = "rules_jvm_external", version = "6.0")
5962

63+
android_sdk_repository_extension = use_extension(
64+
"@rules_android//rules/android_sdk_repository:rule.bzl",
65+
"android_sdk_repository_extension",
66+
)
67+
use_repo(android_sdk_repository_extension, "androidsdk")
68+
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")
69+
6070
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
6171
maven.install(
6272
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@@ -67,6 +77,30 @@ maven.install(
6777
)
6878
use_repo(maven, "maven")
6979

80+
# Define a separate, dev-only extension import for Android deps.
81+
# This prevents downstream non-Android users from having to resolve
82+
# Google Maven (which is required for androidx.*) or rules_android transitively.
83+
grpc_android_maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven", dev_dependency = True)
84+
grpc_android_maven.install(
85+
name = "grpc_android_maven",
86+
artifacts = [
87+
"androidx.annotation:annotation:1.6.0",
88+
"androidx.annotation:annotation-jvm:1.6.0",
89+
"androidx.core:core:1.13.1",
90+
"androidx.lifecycle:lifecycle-common:2.6.2",
91+
],
92+
repositories = [
93+
"https://repo.maven.apache.org/maven2/",
94+
"https://maven.google.com",
95+
],
96+
strict_visibility = True,
97+
# For Bazel 8+ compatibility.
98+
use_starlark_android_rules = True,
99+
# Set this explicitly since the default guess is incorrect under Bzlmod.
100+
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
101+
)
102+
use_repo(grpc_android_maven, "grpc_android_maven")
103+
70104
maven.override(
71105
coordinates = "com.google.protobuf:protobuf-java",
72106
target = "@com_google_protobuf//:protobuf_java",

android/BUILD.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
load("@rules_android//rules:rules.bzl", "android_library")
2+
load("@rules_jvm_external//:defs.bzl", "artifact")
3+
4+
licenses(["notice"])
5+
6+
android_library(
7+
name = "android",
8+
srcs = glob([
9+
"src/main/java/**/*.java",
10+
]),
11+
manifest = "src/main/AndroidManifest.xml",
12+
custom_package = "io.grpc.android",
13+
# TODO(jdcormie): Figure out how to expose this publicly without making
14+
# existing non-android users configure rules_android and maven.google.com.
15+
visibility = ["//:__subpackages__"],
16+
deps = [
17+
"//api",
18+
"//core:internal",
19+
artifact("com.google.code.findbugs:jsr305"),
20+
artifact("com.google.errorprone:error_prone_annotations"),
21+
artifact("com.google.guava:guava"),
22+
],
23+
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package io.grpc;
1818

19-
import javax.annotation.concurrent.ThreadSafe;
2019

2120
/**
2221
* A virtual connection to a conceptual endpoint, to perform RPCs. A channel is free to have zero or
@@ -29,8 +28,9 @@
2928
* implementations using {@link ClientInterceptor}. It is expected that most application
3029
* code will not use this class directly but rather work with stubs that have been bound to a
3130
* Channel that was decorated during application initialization.
31+
*
32+
* <p>This class is thread-safe.
3233
*/
33-
@ThreadSafe
3434
public abstract class Channel {
3535
/**
3636
* Create a {@link ClientCall} to the remote operation specified by the given

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
package io.grpc;
1818

19-
import javax.annotation.concurrent.ThreadSafe;
2019

2120
/**
2221
* A Channel-specific logger provided by GRPC library to {@link LoadBalancer} implementations.
2322
* Information logged here goes to <strong>Channelz</strong>, and to the Java logger of this class
2423
* as well.
24+
*
25+
* <p>This class is thread-safe.
2526
*/
2627
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/5029")
27-
@ThreadSafe
2828
public abstract class ChannelLogger {
2929
/**
3030
* Log levels. See the table below for the mapping from the ChannelLogger levels to Channelz

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package io.grpc;
1818

19-
import javax.annotation.concurrent.ThreadSafe;
2019

2120
/**
2221
* Interface for intercepting outgoing calls before they are dispatched by a {@link Channel}.
@@ -37,8 +36,10 @@
3736
* without completing the previous ones first. Refer to the
3837
* {@link io.grpc.ClientCall.Listener ClientCall.Listener} docs for more details regarding thread
3938
* safety of the returned listener.
39+
*
40+
* <p>This is thread-safe and should be considered
41+
* for the errorprone ThreadSafe annotation in the future.
4042
*/
41-
@ThreadSafe
4243
public interface ClientInterceptor {
4344
/**
4445
* Intercept {@link ClientCall} creation by the {@code next} {@link Channel}.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

2121
import com.google.common.base.MoreObjects;
22-
import javax.annotation.concurrent.ThreadSafe;
2322

2423
/**
2524
* {@link StreamTracer} for the client-side.
25+
*
26+
* <p>This class is thread-safe.
2627
*/
2728
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861")
28-
@ThreadSafe
2929
public abstract class ClientStreamTracer extends StreamTracer {
3030
/**
3131
* Indicates how long the call was delayed, in nanoseconds, due to waiting for name resolution

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import java.util.Collections;
2020
import java.util.List;
2121
import javax.annotation.Nullable;
22-
import javax.annotation.concurrent.ThreadSafe;
2322

2423
/**
2524
* Registry of services and their methods used by servers to dispatching incoming calls.
25+
*
26+
* <p>This class is thread-safe.
2627
*/
27-
@ThreadSafe
2828
public abstract class HandlerRegistry {
2929

3030
/**

0 commit comments

Comments
 (0)