Commit Graph

252 Commits

Author SHA1 Message Date
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
Larry Safran 74137b0978
core: Use SyncContext for InProcessTransport listener callbacks to avoid deadlocks
Fixes deadlocks caused by client and server listeners being called in a synchronized block

Also support unary calls returning null values

Fixes #3084
2022-06-30 13:41:36 -07:00
Adil Ansari a07304471b stub: fix misspelled javadocs 2022-06-27 07:57:44 -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
yifeizhuang 584622c5fa
Revert "stub: enable GRPC_CLIENT_CALL_REJECT_RUNNABLE in ThreadlessExecutor shutdown (#9035)" (#9067)
This reverts commit c53c3ad01b.
2022-04-06 14:01:05 -07:00
yifeizhuang c53c3ad01b
stub: enable GRPC_CLIENT_CALL_REJECT_RUNNABLE in ThreadlessExecutor shutdown (#9035) 2022-04-01 08:51:29 -07:00
Eric Anderson 574fbb4327
stub: Shutdown ThreadlessExecutor only if onClose() is called (#9041)
It is only safe to shutdown the executor if onClose() is called. Normal
RPC completions (both success and failure) will see the future complete,
so this only avoids shutting down in stranger cases like an interceptor
throwing an exception.
2022-04-01 08:49:34 -07:00
yifeizhuang 299851d149
stub: ClientCalls.ThreadlessExecutor throws rejectedExecutorException disable by default (#8973)
* stub: Have ClientCalls.ThreadlessExecutor reject Runnables after end of RPC

Changes originally proposed as part of #7106.

Fixes #3557

* add environment variable rejectExecutedException

Co-authored-by: Nick Hill <nickhill@us.ibm.com>
2022-03-08 10:43:43 -08:00
yifeizhuang 6559ef88a1
Revert "stub: Have ClientCalls.ThreadlessExecutor reject Runnables after end of RPC (#8847)" (#8933)
This reverts commit bb3365731f.
2022-02-18 16:59:33 -08:00
Eduard Wirch 3b6a58ee4d
doc: fix outdated external link
Page is not available on ibm.com anymore. Linking to web archive.
2022-02-16 11:36:54 -08:00
yifeizhuang bb3365731f
stub: Have ClientCalls.ThreadlessExecutor reject Runnables after end of RPC (#8847)
Changes originally proposed as part of #7106.

Fixes #3557

Co-authored-by: Nick Hill <nickhill@us.ibm.com>
2022-02-11 15:08:11 -08:00
Penn (Dapeng) Zhang cf4cd65707 Revert "all: clean up code related to android api level less than 19"
This reverts commit 3ad4d9bfb7.
2022-01-18 10:14:50 -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 3ad4d9bfb7
all: clean up code related to android api level less than 19 2022-01-07 08:13:32 -08:00
yifeizhuang fbded2a05f
default throw ServerCallStreamObserver.setOnCloseHandler (#8564) 2021-09-28 13:31:40 -07:00
Piotr Morgwai Kotarbinski a6abb1b8d9
stub: add ServerCallStreamObserver.setOnCloseHandler(...) (#8452)
This allows for user code to be notified when the messages are actually
put on the wire and the stream is closed.

Fixes #5895
2021-09-21 11:31:04 -07:00
ZHANG Dapeng 29d238afca
api,stub: clarify StreamObserver and Listener param type (#8544) 2021-09-21 10:38:41 -07:00
Benjamin Peterson 67d5f1b0d6 stub: update CallStreamObserver stabilization issue 2021-09-09 09:53:47 -07:00
Eric Anderson 9870db1f47 stub: Document that noop onCancelHandler is useful
setOnCancelHandler tells gRPC that the application is handling
cancellation. But it's fine to have noop behavior within the handler
itself if the application doesn't need it. It is just a way to opt-in to
the more recent no-exception-from-onNext behavior. Let's mention this
use-case in the docs to make it more obvious it is a possibility.

Came up as part of #8409.
2021-09-08 16:48:20 -07:00
Eric Anderson 5cc94a5488
stub: Document StreamObserver is an async API
Missing docs were brought up in #8423
2021-08-30 11:15:05 -07:00
Kurt Alfred Kluever f3337f28ce
stub: Add @InlineMe to deprecated gRPC APIs (#8457)
Read more @ https://errorprone.info/docs/inlineme
2021-08-27 14:11:06 -07:00
Eric Anderson 20ac1999d4
stub: Mark Stub-based MetadataUtils methods deprecated
We don't want other APIs to copy the stub-based API to attach the
interceptor. The API has a shorter name, but isn't actually all that
easier to use and isn't fluent like using the interceptor API.

These are _very_ old methods, so we won't be quick to delete them. Seems
we should have them deprecated at least a year or two; they are easy to
maintain in the mean time.

See API Review notes in #1789
2021-08-06 14:14:17 -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
ZHANG Dapeng 2ca28a2903
stub: stabilize StreamObserver APIs
Resolves #1788
2021-03-10 13:41:31 -08:00
ZHANG Dapeng 9b803f338b
Revert "stub: Have ClientCalls.ThreadlessExecutor reject Runnables after end of RPC" (#7920)
This reverts commit 61e0f30 (#7798).

Our stub/core implementation had a bug (#7921) that might make it possible to leak cancellation through to the executor multiple times, typically when a custom interceptor is used. Revert this commit because import of grpc to google internal fails. We think the bug found in the import is legit and in our code. So we revert this change to avoid hurting users until the underlying issue is fixed.
2021-02-25 15:46:17 -08:00
Nick Hill 61e0f30e38
stub: Have ClientCalls.ThreadlessExecutor reject Runnables after end of RPC
Changes originally proposed as part of #7106.

Fixes #3557
2021-02-23 15:58:05 -08:00
Eric Anderson da939ca762 stub: Stop linking to Guava Javadoc
This resolves the following warning when building with JDK 8 introduced
in 9c5427fd4:
javadoc: warning - Error fetching URL: https://google.github.io/guava/releases/30.0-android/api/docs/

Guava is now building their Javadoc with JDK 11. JDK 11 swapped from
producing package-list to element-list, and stopped creating
package-list entirely. This file is what Javadoc uses to cross-link
documentation, and so it no longer works on the JDK 8 build, even though
the files have virtually the same contents.

ListenableFuture was the only reason we were including the Guava
Javadoc; let's just drop the link instead of worrying about this
silliness.
2020-12-17 17:42:42 -08:00
Eric Anderson 0cd56c29d6
stub: Only throw on cancellation for streaming responses
Unary are far more common than streaming, and we're throwing for unary even
though it doesn't help the service. Let's stop doing that. We also stop
throwing in onComplete() for all cases, because it doesn't help any service;
it doesn't stop the service's processing and isn't even all that informative
since the cancellation can happen even after onComplete() is called.
2020-10-01 13:10:30 -07:00
Eric Anderson 21269bd188
stub: Clarify ServerCallStreamObserver cancellation
This avoids the "changes" description, which could be understood to mean that
the transition is important instead of the steady-state and thus a callback
might not be called (which is not the case).

Much of the language was copied from ServerCall.
2020-07-01 11:58:53 -07:00
Eric Anderson f5b976dd5c stub: Remove useless private method indirection
The method did nothing; just inline its contents. Brought up as part of #7173's
review.
2020-07-01 13:34:22 -05:00
Eric Anderson 613439c97e stub: Reorder blocking request()s for message throughput
This can provide a ~2x performance increase to Netty and 40% increase
for OkHttp. Netty async saw a ~3x gain from MigratingDeframer, so
blocking trails behind a bit. But OkHttp's async gains from
MigratingDeframer were also 40%, so this provides the same gain to
blocking.
2020-06-18 15:48:29 -05:00
Eric Anderson c3ea8e7c91 stub: Document blocking exceptions and async extension types
invoke() needed to be re-defined for Javadoc to display the method.
2020-06-10 16:19:13 -05:00
Eric Anderson 37107d297b stub: Javadoc should not show internal classes 2020-06-10 16:18:26 -05:00
Eric Anderson 0201c5a9a7
stub: Have disableAutoRequest() on server-side
This splits server-side flow control from client-side, but tailors the API for
each case. Client-side continues having disableAutoRequestWithInitial(). While
client-side could have disableAutoRequest(), it seems like it will only rarely
be used and disableAutoRequestWithInitial(0) isn't that bad. So we leave it off
for now; we can always add it in the future.
2020-05-29 15:05:46 -07:00
Ran c5740f893c
Stub: add an util method for setting StubType. (#7045) 2020-05-15 11:45:17 -07:00
Jihun Cho 24823c741f
stub: default impl for disableAutoRequestWithInitial(int) (#7018) 2020-05-07 12:47:28 -07:00
DRayX a9250c1f99
stub: Add disableAutoRequestWithInitial that disables all automatic inbound flow-control requests
Add a new disableAutoRequest method that disables all automatic requests while disableAutoInboundFlowControl maintains existing behavior.

The default behavior of requesting initial messages is applied even if disableAutoInboundFlowControl is called. ServerCalls disables all automatic flow control which is much more useful in case the user can't handle incoming messages until some time after the call has started.  This change creates a new StartableListener that has an onStart method that is invoked when the call is started which makes initial requests if necessary.

See #6806
2020-05-06 10:19:41 -07:00
ZHANG Dapeng 0044f8ce56
all: migrate gradle build to java-library plugin
- Use gradle configuration `api` for dependencies that are part of grpc public api signatures.
- Replace deprecated gradle configurations `compile`, `testCompile`, `runtime` and `testRuntime`.
- With minimal change in dependencies: If we need dep X and Y to compile our code, and if X transitively depends on Y, then our build would still pass even if we only include X as `compile`/`implementation` dependency for our project. Ideally we should include both X and Y explicitly as `implementation` dependency for our project, but in this PR we don't add the missing Y if it is previously missing.
2020-05-04 16:44:30 -07:00
Eric Anderson 4674b27736 api,stub: Improve waitForReady documentation 2020-04-30 16:03:52 -07:00
Eric Anderson 6a50a63ca8 Replace javax.annotation-api with Tomcat's annotations-api
javax.annotation-api is licensed CDDL, which was not noticed when it was
introduced. Tomcat provides an Apache 2 version of the same annotation. Note
that this annotation is only used when compiling with Java 9+.

Unfortunately this may cause classpath collisions since there are _many_ copies
of this annotation on Maven Central; we wanted one canonical source and
javax.annotation-api seemed like that source. We hope this won't impact many
users since we have always suggested using it only for compilation. But it will
probably impact some users. However, we didn't create this mess, this seems to
be "standard practice" for J2EE, which this annotation is now part of, so we're
just impacted by it.

Fixes #6833
2020-04-30 09:14:32 -07:00
Ran 37913fd3b1
stub: add Blocking StubType to blocking ClientCalls methods. (#6900) 2020-04-06 10:55:24 -07:00
Chengyuan Zhang 2734e22ef5
context, stub: check result of CountDownLatch.await() in test (#6664) 2020-01-31 15:03:22 -08:00
Roman Leventov 589a645a38 stub,examples: Clarify CallStreamObserver's Javadoc (#6561)
* Clarify CallStreamObserver's Javadoc
* Remove unnecessary AtomicBoolean and clarify a comment in ManualFlowControlServer
2020-01-28 11:32:09 -08:00
Jihun Cho 16ba163291 stub: fix javadoc to indicate correct version(1.25.0 -> 1.26.0) 2019-12-16 17:08:04 -08:00
Jihun Cho 7db873f1f6
Roll-forward of stub,compiler: generated stub extends Abstract{Async,Future,Blocking}Stub #6196 (#6458)
This reverts commit 2eb3f8c34e (#6317).
2019-11-25 09:41:16 -08:00
Eric Anderson 44b26dab9d stub: Provide bread-crumb to user how to configure StreamObserver before start
This is already in the documentation in CallStreamObserver, but if the user
gets here the error didn't provide an actionable next step. The message now
provides more help of how they should have called the methods instead of
feeling more like a brick wall.
2019-11-20 15:10:39 -08:00
Ran 258a95d0c4
Revert "stub: ignore unary response msg if status is not OK (#6288)" (#6342)
This reverts commit fe46edac
2019-10-28 10:05:28 -07:00
sanjaypujare 7dbf12fe2a
api,stub : fix 2 typos (CallCredentials2 to CallCredentials and javadoc comment in AbstractStub) (#6343) 2019-10-28 10:03:49 -07:00