Commit Graph

197 Commits

Author SHA1 Message Date
Eric Anderson ff8e413760
Remove direct dependency on j2objc
Bazel had the dependency added because of #5046, where Guava was
depending on it as compile-only and Bazel build have "unknown enum
constant" warnings. Guava now has a compile dependency on j2objc, so
this workaround is no longer needed. There are currently no version skew
issues in Gradle, which was the only usage.
2024-08-13 21:33:55 -07:00
Eric Anderson 7ba293f49f
Upgrade ErrorProne Core to 2.28.0 2024-07-12 14:59:20 -07:00
hakusai22 6ec744f2a0
Fix various typos (#11144) 2024-05-06 20:29:44 -07:00
Laglangyue 52e65ec0d8
minor: remove the unnecessary final,static (#11098) 2024-04-18 15:26:01 -07:00
Eric Anderson 32d48ae89a bazel: Fix formatting with buildifier
Keys and dependencies are sorted.
2024-04-04 11:50:07 -07:00
David Burns 00649913b0
bazel: Use the `artifact` macro for loading maven deps
The recommended way to load dependencies from `rules_jvm_external`
is to make use of the `@maven` workspace, and the most readable
way of doing that is to use the `artifact` macro provides.

This removes the need to generate the "compat" namespaces, which
`rules_jvm_external` provided for backwards compatibility with
older releases. This change also sets things up for supporting
`bzlmod`: this requires all workspaces accessed by a library to
be named "up front" in the `MODULE.bazel` file. This way, the
only repo that needs to be exported is `@maven`, rather than the
current huge list.
2024-03-28 14:33:32 -07:00
Sergii Tkachenko ebbe0673f3
alts,census,gcp-observability: Explicitly set grpc-context as an implementation dependency (#10997)
Override google-auth `io.grpc:grpc-context` dependency with our own
`project(":grpc-context")`.

This fixes the issue with classes depending on `grpc-alts`
implementation receiving very (!) old `io.grpc:grpc-context:1.27.2`
as a transitive dependency of `com.google.auth`.

Projects `grpc-census` `grpc-gcp-observability` are affected in the
similar way, except `io.grpc:grpc-context:1.59.1` is pulled as  a
transitive dependency of `io.opencensus`.

### Before
```
❯ ./gradlew -q :grpc-xds:dependencyInsight --configuration=compileClasspath --dependency=io.grpc:grpc-context
*** Skipping the build of codegen and compilation of proto files because skipCodegen=true
  * Skipping the build of Android projects because skipAndroid=true
io.grpc:grpc-context:1.27.2
  Variant compile:
    | Attribute Name                 | Provided | Requested    |
    |--------------------------------|----------|--------------|
    | org.gradle.status              | release  |              |
    | org.gradle.category            | library  | library      |
    | org.gradle.libraryelements     | jar      | classes      |
    | org.gradle.usage               | java-api | java-api     |
    | org.gradle.dependency.bundling |          | external     |
    | org.gradle.jvm.environment     |          | standard-jvm |
    | org.gradle.jvm.version         |          | 8            |

io.grpc:grpc-context:1.27.2
\--- io.opencensus:opencensus-api:0.31.1
     +--- com.google.http-client:google-http-client:1.43.3
     |    +--- com.google.auth:google-auth-library-oauth2-http:1.22.0
     |    |    \--- project :grpc-alts
     |    |         \--- compileClasspath
     |    \--- com.google.http-client:google-http-client-gson:1.43.3
     |         \--- com.google.auth:google-auth-library-oauth2-http:1.22.0 (*)
     \--- io.opencensus:opencensus-contrib-http-util:0.31.1
          \--- com.google.http-client:google-http-client:1.43.3 (*)

(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.
```

### After
```
❯ ./gradlew -q :grpc-xds:dependencyInsight --configuration=compileClasspath --dependency=io.grpc:grpc-context
*** Skipping the build of codegen and compilation of proto files because skipCodegen=true
  * Skipping the build of Android projects because skipAndroid=true
project :grpc-context
  Variant apiElements:
    | Attribute Name                 | Provided | Requested    |
    |--------------------------------|----------|--------------|
    | org.gradle.category            | library  | library      |
    | org.gradle.dependency.bundling | external | external     |
    | org.gradle.jvm.version         | 8        | 8            |
    | org.gradle.libraryelements     | jar      | classes      |
    | org.gradle.usage               | java-api | java-api     |
    | org.gradle.jvm.environment     |          | standard-jvm |
   Selection reasons:
      - By conflict resolution: between versions 1.63.0-SNAPSHOT and 1.27.2

project :grpc-context
\--- project :grpc-alts
     \--- compileClasspath

io.grpc:grpc-context:1.27.2 -> project :grpc-context
\--- io.opencensus:opencensus-api:0.31.1
     +--- com.google.http-client:google-http-client:1.43.3
     |    +--- com.google.auth:google-auth-library-oauth2-http:1.22.0
     |    |    \--- project :grpc-alts
     |    |         \--- compileClasspath
     |    \--- com.google.http-client:google-http-client-gson:1.43.3
     |         \--- com.google.auth:google-auth-library-oauth2-http:1.22.0 (*)
     \--- io.opencensus:opencensus-contrib-http-util:0.31.1
          \--- com.google.http-client:google-http-client:1.43.3 (*)

(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.
```
2024-03-11 14:00:12 -07:00
Eric Anderson d6830d7f99
Change many api deps to implementation deps
These look pretty fair now, mostly only exposing grpc-api and
annotations as api dependencies.
2023-12-15 15:14:29 -08:00
sanjaypujare 15fc70be2a
core, netty, okhttp: implement new logic for nameResolverFactory API in channelBuilder (#10590)
* core, netty, okhttp: implement new logic for nameResolverFactory API in channelBuilder
fix ManagedChannelImpl to use NameResolverRegistry instead of NameResolverFactory
fix the ManagedChannelImplBuilder and remove nameResolverFactory

* Integrate target parsing and NameResolverProvider searching

Actually creating the name resolver is now delayed to the end of
ManagedChannelImpl.getNameResolver; we don't want to call into the name
resolver to determine if we should use the name resolver.

Added getDefaultScheme() to NameResolverRegistry to avoid needing
NameResolver.Factory.
---------

Co-authored-by: Eric Anderson <ejona@google.com>
2023-11-03 09:57:59 -07:00
erm-g 4fbefe9f0f
alts: Add propagation of original exception for AltsHandshakerStub (#10644)
This PR addresses a bug which is a part of #9058. It propagates the
original exception caught at AltsHandshakerStub.Reader.onError().
2023-11-03 07:50:52 -07:00
Sergii Tkachenko a294b27d52
core: Deprecate ForwardingChannelBuilder (#10587)
Deprecate `ForwardingChannelBuilder` in favor of `ForwardingChannelBuilder2`.
2023-11-02 10:58:20 -07:00
Eric Anderson 073ca92e24
alts: Re-enable deprecation warnings (#10640)
google/protobuf#4046 was fixed a long time ago. Recently noticed when
working on ForwardingChannelBuilder(2).
2023-11-02 10:09:09 -07:00
sanjaypujare 41552bfd9a
all: generate automatic module name in the manifest (#10413) 2023-07-25 09:00:11 -07:00
Eric Anderson fefbd12c7e Remove unnecessary thisUsesUnstableApi from CallCredentials impls
This method has been unnecessary/deprecated since dd2dc21d.
2023-07-18 13:38:24 -07:00
Philip K. Warren 3808e707f9
compiler: Use fully qualified String in codegen (#10321)
Currently, the gRPC compiler isn't properly using the fully qualified
string name `java.lang.String` instead of `String`. Update the generator
to use the `$String$` alias to avoid compile issues with protobuf
messages called String.

Fixes #10316.
2023-06-29 10:50:13 -07:00
Eric Anderson f46793e82d Remove unneeded dependency excludes
Since 44847bf4e, when we upgraded our JUnit version, the JUnit
exclusions have probably not been necessary. e0ac97c4f upgraded
Robolectric to a version that had the auto.service problem fixed.
2023-06-23 11:18:10 -07:00
Eric Anderson 29b8483fd6
Use test fixtures instead of sourceSets.test.output
This avoids the (often missing) evaluationDependsOn and fixes using
results from other projects without propagating those through
Configuration. It also reduces the number of useless classes pulled in
by down-stream tests, reducing the probability of rebuilds.

The expectation of fixtures is they help testing down-stream code that
use the classes in main. That applies to all the classes here except for
FakeClock and StaticTestingClassLoader. It would also apply to many
internal classes in grpc-testing, but let's consider cleaning that up
future work.
2023-05-16 12:10:13 -07:00
Eric Anderson 2cc24a9bda gradle: Remove version pinning from POMs
The pinning is unreliable in Maven and ignored by Gradle. I'm not at all
convinced that we are pinning/not pinning in appropriate projects. The
pinning also serves less of a purpose since we started encouraging the
BOM and grpc-netty-shaded. Netty's HTTP/2 API has also become somewhat
stable compared to its earlier history. If we notice an up-tick in
version skew, we can reinstate it.

The pinning is annoying in the build.gradle code and causes Maven/Gradle
to download the version list once a day, which can be troublesome to
users unaware of how to tell the tools to work offline.

It also opens our users to platform issues like seen in #10043
and #10086 where Maven Central's version list was incorrectly generated.
Or like #9664 where Gradle Plugin's repository caches packages from
JCenter but the version list is not as cachable so exposed us to JCenter
instability.

This fixes #8357, by way of "we think we won't worry any more." See
90db93b9 when it was originally introduced. And issues
like #8337, #3634.
2023-05-15 13:08:40 -07:00
Larry Safran 9204223c16
alts:Remove character dropped from error message (#10068)
The DECRYPTION_FAILURE_RE matcher had an exclamation point that was dropped from the related error message between Java 11 and 19.

Fixes #10011
2023-04-20 11:05:36 -07:00
Eric Anderson 1551cc7403 Upgrade Protobuf Java to 3.22.3 (aka 22.3)
The version used by protoc-gen-grpc-java will be upgraded separately,
because of large C++ build changes necessary. But that won't impact
users at all. We are upgrading to protoc 22.3; only the grpc plugin is
not upgraded.

Bazel is upgraded for both Java and C++.
2023-04-17 13:16:20 -07:00
Matthew Stevenson 11a1f9e3e8
alts: Enable user to configure max number of concurrent ALTS handshakes. (#10016) 2023-04-10 10:49:04 -07:00
Benjamin Peterson ae6c506f96
all: fix build with errorprone 2.18 (#9886)
errorprone cannot be updated past 2.10 because later versions do not support Java 8.

Fixes https://github.com/grpc/grpc-java/issues/9916.
2023-03-01 13:45:18 -08:00
Larry Safran 19eab29f8d
compiler: Generate interfaces for services to implement (#9688)
Introduce an AsyncService interface in the generated code and move the methods from <service>ImplBase to default implementation of the interface.
* update pom files to allow java 1.8
* Add a bindService(<service>Async) method
* Change TestServiceImpl to use the interface and include a bind method instead of extending TestServiceImplBase.
2023-02-15 10:33:44 -08:00
Eric Anderson d17a2db4bd Upgrade to Checkstyle 8.28
Trying to upgrade Gradle to 7.6 improved the checkstyle plugin such that
it appears to have been running in new occasions. That in turn exposed
us to https://github.com/checkstyle/checkstyle/issues/5088. That bug was
fixed in 8.28, which also fixed lots of other bugs. So now we have
better checking and some existing volations needed fixing. Since the
code style fixes generated a lot of noise, this is a pre-fix to reduce
the size of a Gradle upgrade.

I did not upgrade past 8.28 because at some point some other bugs were
introduced, in particular with the Indentation module. I chose the
oldest version that had the particular bug impacting me fixed. Upgrading
to this old-but-newer version still makes it easier to upgrade to a
newer version in the future.
2023-01-05 17:07:04 -08:00
Larry Safran 01d5bd47cb
Cleanup some of the warnings across the code base (#9445)
No logic changes, just cleans up warnings to make spotting real problems easier.

Remove "public" declarations on interfaces
Remove duplicate semicolons (Java lines ending in ";;")
Remove unneeded import
Change non-javadoc comment to not start with "/**"
Remove unneeded explicit type declarations from generics
Fix broken javadoc links
2022-08-15 11:06:31 -07:00
Eric Anderson 61f19d707a
Swap Animalsniffer to Java 8 and Android 19
Also added missing signatures. Swapping to version catalog will make
this process easier in the future.
2022-08-10 12:41:57 -07:00
Eric Anderson 0ff9f37b9e Use Gradle's task configuration avoidance APIs
This can avoid creating an additional 736 tasks (previously 502 out of
1591 were not created). That's not all that important as the build time
is essentially the same, but this lets us see the poor behavior of the
protobuf plugin in our own project and increase our understanding of how
to avoid task creation when developing the plugin. Of the tasks still
being created, protobuf is the highest contributor with 165 tasks,
followed by maven-publish with 76 and appengine with 53. The remaining
59 are from our own build, but indirectly caused by maven-publish.
2022-07-08 12:16:40 -07:00
Terry Wilson 7bd0797496
all: Update netty to 4.1.77.Final and netty_tcnative to 2.0.53.Final (#9027)
all: Update netty to 4.1.77.Final and netty_tcnative to 2.0.53.Final

Also switches to a non-release version of rules_jvm_external to allow Bazel build to work with artifact classifiers.
2022-06-24 10:47:27 -07:00
Eric Anderson b06942d63b Use Gradle's version catalog
This moves our depedencies into a plain file that can be read and
updated by tooling. While the current tooling is not particularly better
than just using gradle-versions-plugin, it should put us on better
footing. gradle-versions-plugin is actually pretty nice, but will be
incompatible with Gradle 8, so we need to wait a bit to see what the
future holds.

Left libraries as an alias for libs to reduce the commit size and make
it easier to revert if we don't end up liking this approach.

We're using Gradle 7.3.3 where it was an incubating fetaure. But in
Gradle 7.4 is became stable.
2022-06-14 14:04:10 -07:00
Eric Anderson 5b825e8b17 Remove classifiers from ext.libraries
Classifier can't be specified in version catalog.
2022-06-14 14:04:10 -07:00
yifeizhuang a738bc8f22
alts: support google credential CFE cluster name in XDSTP format (#9246) 2022-06-08 14:26:47 -07:00
Eric Anderson a206cda1a8 Change Attributes.Key debug strings to reference the API of the key
Users appear to be doing `attributes.toString()` to find keys they are
interested in and then unable to find the name of the Key in our API.
They workaround the problem by scanning through `attributes.keys()`
looking for the key of interest. This is an abuse of the keys() API and
unnecessary user friction. They'd happily use the API if they just knew
where to find it.

I added internal to some strings to make it clear that you shouldn't go
looking to use it. There were many strings I didn't change. I focused on
keys most likely to be seen by users, which meant keys in grpc-api and
keys that are available via transport attributes.

See https://github.com/grpc/grpc-java/issues/1764#issuecomment-1139250061
2022-06-02 16:11:02 -07:00
ZHANG Dapeng d1e0be6919
all: fix various gradle build warnings 2022-01-18 10:18:16 -08:00
Eric Anderson 7cf048eb28
Drop Java 7 support
Oracle's Premier Support for Java 7 ended in July 2019. Per gRFC P5,
dropping support for the only release. Android is able to desugar many
Java 8 language features.
2022-01-18 07:17:51 -08:00
Eric Anderson 58a7ace6ac
Bump ErrorProne to 2.10.0
Previous versions of error prone were incompatible with Java 17 javac.

In grpc-api, errorprone is now api dependency because it is on a public
API.  I was happy to see that Gradle failed the build without the dep
change, although the error message wasn't super clear as to the cause.

It seems that previously -PerrorProne=false did nothing. I'm guessing
this is due to a behavior change of Gradle at some point. Swapping to
using the project does build without errorProne, although the build
fails with Javac complaining certain classes are unavailable. It's
unclear why. It doesn't seem to be caused by the error-prone plugin.
I've left it failing as a pre-existing issue.

ClientCalls/ServerCalls had Deprecated removed from some methods because
they were only deprecated in the internal class, not the API. And with
Deprecated, InlineMeSuggester complained.

I'm finding InlineMeSuggester to be overzealous, complaining about
package-private methods. In time we may figure out how to use it better,
or we may request changes to the checker in error-prone.
2022-01-12 12:06:27 -08:00
ZHANG Dapeng cb4b91418c
javadoc: update new API `@since` version (#8727)
The @since version in commits 5a3b8e2 and a2398ce were missing and incorrect respectively.
2021-11-29 10:22:32 -08:00
Mohan Li a2398ce5db
alts: Make GoogleDefaultChannelCredentials take a CallCredentials (#8548)
DirectPath is going to support non-default service account. This commit
allows users to pass CallCredentials to GoogleDefaultChannelCredentials.
See design in go/directpath-file-credential-google-default-creds
2021-11-15 15:46:56 -08:00
Zhouyihai Ding cf41181c48
alts: add channel logs in handshake
The logs are to help with debugging issues for an internal customer.
2021-09-22 21:40:41 -07:00
Eric Anderson 0cabf5672a compiler: Add GrpcGenerated annotation to generated class
This can be used by annotation processors to avoid processing the
gRPC-generated code. The normal Generated annotation only has SOURCE
retention, so isn't available to annotation processors.

I don't include the service name within the annotation as that assumes
we'll never have need for any other type of generated class. If there's
a request for exposing service name via an annotation in the future, we
can make an RpcService annotation or the like.

Fixes #8158
2021-07-02 22:11:40 -07:00
Eric Anderson 5642e01243
Replace failOnVersionConflict() with custom requireUpperBoundDeps
failOnVersionConflict has never been good for us. It is equivalent to
Maven dependencyConvergence which we discourage our users to use because
it is too tempermental and _creates_ version skew issues over time.
However, we had no real alternative for determining if our deps would be
misinterpeted by Maven.

failOnVersionConflict has been a constant drain and makes it really hard
to do seemingly-trivial upgrades. As evidenced by protobuf/build.gradle
in this change, it also caused _us_ to introduce a version downgrade.

This introduces our own custom requireUpperBoundDeps implementation so
that we can get back to simple dependency upgrades _and_ increase our
confidence in a consistent dependency tree.
2021-06-11 14:01:18 -07:00
Chengyuan Zhang 505594ac53
xds: change google_default/compute_engine creds to select TLS if the xDS cluster name is prefixed with 'google_cfe_' (#8152)
Following up changes in bbc5f61abb, the cluster_resolver LB policy uses the hostname received in CDS responses for discovering LOGICAL_DNS cluster endpoints.

Based on the new design, TD will generate a CFE cluster called "google_cfe_${service_name}" (e.g., for DirectPath service "cloud-bigtable.googleapis.com", the cluster name will be "google_cfe_cloud-bigtable.googleapis.com") for each DirectPath service. google_default/compute_engine creds will identify CFE clusters by the name having the prefix "google_cfe_".
2021-05-26 12:06:23 -07:00
Eric Anderson 16eb5a47ec Stabilize ChannelCredentials
Some of the experimental API annotations were changed to other issues or
became `@Internal` to match their related APIs.

Fixes #7479
2021-05-03 16:22:43 -07:00
Eric Anderson d42f3b8fcb Stabilize ServerCredentials
Some of the experimental API annotations were changed to other issues or
became @Internal to match their related APIs.

Fixes #7621
2021-05-03 16:10:24 -07:00
Chengyuan Zhang b2e475712d
alts: make both GoogleDefaultChannelCredentials and ComputeEngineChannelCredentials choose ALTS for backends given by xDS TD (#7999)
GoogleDefaultChannelCredentials and ComputeEngineChannelCredentials are literally the same thing for DirectPath, both of them should behave the same for choosing the protocol negotiator for talking to backends given by Traffic Director.
2021-03-19 17:01:05 -07:00
yifeizhuang 528ef63c58
core: Move negotiationLogger from channel attributes to GrpcHttp2ConnectionHandler (#7933) 2021-03-10 16:43:56 -08:00
Jiangtao Li bb737a2e31
alts: remove confusing constant name in InternalCheckGcpEnvironment.java (#7954) 2021-03-10 10:00:44 -08:00
Chengyuan Zhang 9e2c817cd8 Make AltsServerBuilder extend ForwardingServerBuilder. 2021-03-05 10:03:22 -08:00
Chengyuan Zhang a598b973a3
api: add ServerBuilder.addServices() API (#7926) 2021-02-28 23:36:27 -08:00
Chengyuan Zhang 2bfa0037ad
xds: implement cloud-to-prod resolver (#7900)
Implemented CloudToProdNameResolver, which will be used for DirectPath with URI scheme "google-c2p". The resolver is only a wrapper that delegates name resolution either to DNS or xDS resolver depending on the environment. If it is delegating to the xDS resolver, it will send HTTP requests (to a local HTTP server) to fetch metadata that is used to generate a bootstrap config. The self-generated bootstrap will be used for xDS.
2021-02-23 12:27:47 -08:00
Eric Anderson 1161ad9ed8 alts: Make concurrent handshake limit part of ALTS instead of TSI
The handshake limit is more a property of ALTS than TSI. This allows
other TSI implementations to accept a high connection rate (b/179376431)
2021-02-12 17:11:21 -08:00