Commit Graph

405 Commits

Author SHA1 Message Date
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
Chengyuan Zhang b8bcf98f33
okhttp: use new APIs to configure TLS in Android (roll forward #6959) (#6960)
* Revert "okhttp: revert changes for using new APIs to configure TLS in Android (#6959)"

This reverts commit ee8b395f79.

Roll forward with adding manual check if hostname contains underscore, as Android's URI implementation allows underscore in hostsname.
2020-04-22 10:28:56 -07:00
Chengyuan Zhang ee8b395f79
okhttp: revert changes for using new APIs to configure TLS in Android (#6959)
* Revert "okhttp: Skip enabling SNI and session ticket for fake/test host names (#6949)"

This reverts commit eb8e31409e.

* Revert "okhttp: use new APIs for configuring TLS whenever possible (Android Q+) (#6912)"

This reverts commit 5803dfd9dc.
2020-04-21 15:05:53 -07:00
Chengyuan Zhang eb8e31409e
okhttp: Skip enabling SNI and session ticket for fake/test host names (#6949)
Work around for cases (usually for tests) where hostname is overridden for test certs and it is in invalid syntax.
2020-04-20 17:30:01 -07:00
Chengyuan Zhang 5803dfd9dc
okhttp: use new APIs for configuring TLS whenever possible (Android Q+) (#6912)
Use new APIs for configuring TLS in Android environment. Starting from Android 29, there is a new set of public APIs for configuring ALPN (and starting from Android 24, there is API for enabling SNI). This change migrates to use these new APIs whenever possible. Only fallback to call the old hidden APIs if new ones do not exist (or do not work).
2020-04-17 11:44:08 -07:00
Eric Anderson 186cfebcba all: Move jacocoTestReport exclusions to individual projects
The sourceSets.main.output.collect should probably be improved at some point to
improve loading performance, but this is technically better than what we had
before so let's call it a win and move on.
2020-04-01 10:33:32 -07:00
chrisschek bf2a66c8a2
okhttp: fix incorrect connection-level flow control handling at beginning of connection
Specifically, this addresses bugs that occur when the `OkHttpChannelBuilder.flowControlWindow(int)` setting is increased from its default value.

Two changes:
1. On starting a connection, ensure the value of `OkHttpChannelBuilder.flowControlWindow(int)` is sent via Settings.INITIAL_WINDOW_SIZE. Also send a WINDOW_UPDATE after Settings to update the connection-level window.
2. Always initialize the `OutboundFlowController` with an initialWindowSize of 65335 bytes per the [http2 spec](https://http2.github.io/http2-spec/#InitialWindowSize) instead of using the inbound window size.

Fixes #6685
2020-02-27 12:34:23 -08:00
sanjaypujare dba09163de
netty: remove 'grpc-exp' from the list of next-protocol-versions in ALPN (#6592) 2020-01-09 16:41:20 -08:00
Tomo Suzuki 75f6fd8f10 Upgrade error_prone_annotations to 2.3.4 2020-01-03 14:50:34 -08:00
Graeme Morgan d3c77f2d87 all: Add suppressions for GuardedBy violations
This supports releasing a new version of GuardedBy which finds more mistakes than it used to.

Filed #6578 to try to clean up the suppressions.
2019-12-30 10:17:05 -08:00
Tomo Suzuki 29638780ae build: Replaced outdated comments (#6492) 2019-12-05 13:53:51 -08:00
ZHANG Dapeng 2d454d478c
Revert "Revert "all: remove deprecated usePlaintext(boolean)""
This reverts commit 316a739e67.
2019-11-18 16:53:52 -08:00
Jihun Cho 30f8f26f7a okhttp: use FINE log for pure IOExceptions 2019-10-24 15:17:16 -07:00
Carl Mastrangelo f2d0f87d2e compiler: set safe and idempotent bits on method descriptors 2019-10-22 10:59:11 -07:00
ZHANG Dapeng 316a739e67
Revert "all: remove deprecated usePlaintext(boolean)"
This reverts commit 296857b4e7.
2019-10-10 15:56:47 -07:00
Ran ba17682eb2
okhttp: fix header scheme does not match transport type. (#6260)
okhttp: fix header scheme does not match transport type.
2019-10-09 18:00:45 -07:00
Chengyuan Zhang b69f19d589
okhttp: add full implementation of HPACK header compression (#6026)
This change added the missing implementation of HTTP/2 HPACK for writer. The implementation is copied (and modified) from upstream OkHttp (OkHttp3). 

- Huffman encoding of writer is disabled by default.
2019-10-08 10:06:26 -07:00
ZHANG Dapeng 296857b4e7
all: remove deprecated usePlaintext(boolean) 2019-10-08 09:27:39 -07:00
Jihun Cho e9ac1b4a76
all: update modules to wait until other module's sourceSet is available (#6232) 2019-10-02 15:05:44 -07:00
Carl Mastrangelo ab2aff48dc netty,okhttp,cronet: add option to use get/put when methods are safe/idempotent
This change adds two booleans to the ChannelBuilders to
allow transports to use get and put.   These are currently defaulted to
on, but unset on the method descriptors.   This change is 1/2 that will
allow the safe / idempotent bits to be set on generated proto code.
Part 2/2 will actually enable it.

The use case for this is for interceptors that implement caching logic.
They need to be able to access the safe/idempotent bits on the MD in
order to decide to how to handle the request, even if gRPC doesn't use
GET / PUT HTTP methods.
2019-09-25 14:57:17 -07:00
Eric Anderson 2b945774b6 Apply animalsniffer plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 4215b80b81 Apply java plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson e13221b503 Apply japicmp plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 5b838e5284 Apply maven-publish plugin explicitly when needed 2019-09-13 09:42:17 -07:00
康智冬 415212fc49 alts: fix typo (#6113) 2019-09-10 14:13:35 -07:00
Carl Mastrangelo 4c1e197fcd
okhttp: remove unused import 2019-08-15 16:00:02 -07:00
Chengyuan Zhang ad47eee4d3
okhttp: add PerfMark tracing for okhttp transport (#6038)
* okhttp: add PerfMark tracing for okhttp transport

* change task for AsyncSink to give more accurate task description

* add final to field tag

* add PerfMark dependency in okhttp package bazel
2019-08-14 17:20:29 -07:00
Dharmesh Jogadia 5790503d79 core,okhttp: removed GrpcUtil.IS_RESTRICTED_APPENGINE and dependent code (#6051) 2019-08-13 10:11:56 -07:00
Eric Anderson 26bd76fa76
Upgrade to Gradle 5 2019-06-07 08:40:53 -07:00
Carl Mastrangelo 7657523b28
all: update to error prone 2.3.3 2019-06-05 15:28:43 -07:00
Tim van der Lippe ad0893737e Migrate org.mockito.Matchers#any* to org.mockito.ArgumentMatchers
The former is deprecated and replaced by the latter in Mockito 2.
However, there is a functional difference: ArgumentMatchers will reject
`null` and check the type if the matcher specified a type (e.g.
`any(Class)` or `anyInt()`). `any()` will remain to accept anything.
2019-05-29 16:53:01 -07:00
Eric Anderson 2cbc540cb3 Remove deprecated enableKeepAlive API from transports
As mentioned in 5188[1], the default used with the enableKeepAlive API
conflicted with the default server enforcement. Instead of fixing it,
remove it. These APIs were deprecated in v1.3.0 in April 2017.

1. https://github.com/grpc/grpc-java/issues/5188#issuecomment-482269303
2019-05-28 16:37:02 -07:00
Eric Anderson 80c3c992a6 core: Move io.grpc to grpc-api
io.grpc has fewer dependencies than io.grpc.internal. Moving it to a
separate artifact lets users use the API without bringing in the deps.
If the library has an optional dependency on grpc, that can be quite
convenient.

We now version-pin both grpc-api and grpc-core, since both contain
internal APIs.

I had to change a few tests in grpc-api to avoid FakeClock. Moving
FakeClock to grpc-api was difficult because it uses
io.grpc.internal.TimeProvider, which can't be moved since it is a
production class. Having grpc-api's tests depend on grpc-core's test
classes would be weird and cause a circular dependincy. Having
grpc-api's tests depend on grpc-core is likely possible, but weird and
fairly unnecessary at this point. So instead I rewrote the tests to
avoid FakeClock.

Fixes #1447
2019-04-16 21:45:40 -07:00
Jihun Cho 4887d99c2f
okhttp: wait until connection preface / settings during transport start to avoid deadlock (#5567) 2019-04-09 13:19:28 -07:00
Chengyuan Zhang 74527dcee9
okhttp: fix OkhttpFrameLogger mocking tests failure (#5565)
* use LogRecord to verify OkHttpFrameLogger in OkHttpClientTransportTest

* use LogRecord to test OkHttpFrameLogger in ExceptionHandlingFrameWriterTest
2019-04-08 18:06:25 -07:00
Chengyuan Zhang 0db0c637a1
okhttp: add verbose logging for OkHttp HTTP/2 frame content (#5488)
* okhttp: add verbose logging for OkHttp HTTP/2 frames to include brief frame content.

* fix small details and typo issues

* fix branch condition (it's a typo) for logging the whole buffer

* remove redudent log level checking, always not log entire buffer

* convert ByteString to String to avoid printing 'hex=' prefix

* add test for OkHttpFrameLogger for inbound http frames

* refactor OkHttpFrameLogger's help method

* add Constructor for testing and missing logHeaders

* add http/2 framelogger test for outbound side

* use ArgumentMatchers instead of Matchers

* replace assertTrue with Truth.assertThat

* assert buffer log with exact length match instead of <=
2019-04-04 15:35:19 -07:00
Tim van der Lippe d35fbd7eee all: Update to Mockito 2
This is the public port of cl/238445847

Fixes #5319
2019-03-19 14:17:52 -07:00
Carl Mastrangelo 801cc5c189
core,netty,okhttp: propagate the subchannel logger to the transport 2019-03-04 15:16:53 -08:00
Kun Zhang 59a336c3ae
core: add internal transport attribute ATTR_CLIENT_EAG_ATTRS (#5420)
This is needed for GRPCLB pick_first support, which needs to attach
tokens to headers, and the tokens are per server. In pick_first, all
addresses are in a single Subchannel, thus the LoadBalancer needs to
know which backend is used for a new stream.
2019-03-04 12:38:26 -08:00
Eric Anderson a818c81a71 testing: Move AbstractTransportTest to core to avoid Truth dep
Fixes #5301
2019-02-28 21:33:19 -07:00
Kun Zhang 83b92cfc9f
core: pass transport attributes to ClientStreamTracer.Factory.newClientStreamTracer() (#5380)
This will be a new override.  The old override is now deprecated.

In order to pass new information without adding new overrides, I shoved most information
into an object called StreamInfo.  The Metadata is left out to draw attention because
it's mutable.

Motivation: this is needed for correctly supporting pick_first in GRPCLB.  GRPCLB needs to
add a token to the headers, and the token varies among servers.  With round_robin, GRPCLB
create a Subchannel for each server, thus can attach the token when the Subchannel is picked.
To implement pick_first, all server addresses will be put in a single Subchannel, we will
need to add the header in newClientStreamTracer(), by looking up the server address from
the transport attributes and deciding which token to add.
2019-02-21 11:13:51 -08:00
Eric Gribkoff 6c32eaf9d4
okhttp: add socketFactory method to channel builder (#5378) 2019-02-20 19:17:20 -08:00
Kun Zhang e875a8c6a3
core: introduce NameResolver.Helper and deprecate the params on newNameResolver() (#5345)
Context: [#4159 (comment)](https://github.com/grpc/grpc-java/issues/4159#issuecomment-415827641)

`Attributes` is appropriate for plumbing optional objects, especially useful for a long plumbing path where components in the middle may not care or see all objects in the container. It's not the case for the `params` on `newNewResolver()`. Both the default port and the proxy detector are guaranteed to be there and the plumbing path is very short. In this case, a first-class object is more appropriate and easier to use.

The `Helper` will also have `getSynchronizationContext()` (#2649) and a method to parse and validate service config. We we also considering merging `Listener` into the `Helper`, to make `NameResolver` match the `LoadBalancer` API.
2019-02-12 10:14:59 -08:00
Kun Zhang 138e958c4a
core: ProxiedSocketAddress on public API (#5344)
Combine the public `ProxyParameters` and the internal `ProxySocketAddress` as `HttpConnectProxiedSocketAddress`. The more specific name signifies the type of the proxy we currently support, and makes room for other proxy types (e.g., SOCKS) in the future. The combination simplifies NameResolver implementation.

Introduce `ProxiedSocketAddress` as the base class that is returned by `ProxyDetector`, mainly for clarification and documentation. Added documentation about proxy in general on `ProxyDetector`.
2019-02-11 09:56:59 -08:00
Carl Mastrangelo f6ec07d87d
core,netty: expose listening on multiple ports 2019-02-06 15:49:59 -08:00
Carl Mastrangelo 3a39b81cf5
all: remove java6 type args 2019-02-04 10:03:50 -08:00
Eric Anderson 723851627e okhttp: Remove DEFAULT_CONNECTION_SPEC from builder
This will reduce the method count, as okhttp's copy of ConnectionSpec will no
longer be retained when ProGuarded. It was deprecated in 25f357699, 10 months
ago.
2019-02-01 09:36:37 -08:00
Carl Mastrangelo ed0a9f3f1d
netty: support listening on multiple ports 2019-01-29 10:13:40 -08:00
Carl Mastrangelo f6689a1f86
all: fix lint errors 2019-01-25 16:09:59 -08:00
Eric Gribkoff 1d97b50315
core: do not lose status when RST_STREAM with NO_ERROR received (#5264) 2019-01-24 08:50:09 -08:00