Commit Graph

485 Commits

Author SHA1 Message Date
Carl Mastrangelo 4e3ee4471e
all: use PerfMark.traceTask (#9950)
* all: use PerfMark.traceTask

* make linter happy
2023-04-18 10:46:54 -07:00
yifeizhuang 046e02bcdf
okhttp: forceful close after MAX_CONNECTION_AGE_GRACE_TIME (#9968) 2023-03-27 15:31:14 -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
Eric Anderson 9de989bd64 okhttp: Avoid DNS lookup in test
Our tests assume localhost is in /etc/hosts or uses some other form of
local-only resolution. But that wouldn't apply to "host". What was
happening is this was causing a DNS resolution, which would fail, and
the InetSocketAddress would be "unresolved". Thus, the equivalent and
faster code would be `InetSocketAddress.createUnresolved("host", 1234)`.
But there doesn't seem to be any reason to avoid localhost in this test,
so swap to the more typical solution instead.

This should avoid flakes like:
```
io.grpc.okhttp.OkHttpClientTransportTest > invalidAuthorityPropagates FAILED
    org.junit.runners.model.TestTimedOutException: test timed out after 10 seconds
        at java.base@11.0.17/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.base@11.0.17/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
        at java.base@11.0.17/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1529)
        at java.base@11.0.17/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
        at java.base@11.0.17/java.net.InetAddress.getAllByName0(InetAddress.java:1519)
        at java.base@11.0.17/java.net.InetAddress.getAllByName(InetAddress.java:1378)
        at java.base@11.0.17/java.net.InetAddress.getAllByName(InetAddress.java:1306)
        at java.base@11.0.17/java.net.InetAddress.getByName(InetAddress.java:1256)
        at java.base@11.0.17/java.net.InetSocketAddress.<init>(InetSocketAddress.java:220)
        at app//io.grpc.okhttp.OkHttpClientTransportTest.invalidAuthorityPropagates(OkHttpClientTransportTest.java:1687)
```
2023-01-19 10:51:20 -08:00
Eric Anderson d761fc6db9 okhttp: Remove unnecessary client certs in TlsTest
This simplifies the tests and makes them more clear. basicTls_succeeds
was added to confirm excluding the client cert functions.
2023-01-09 14:57:25 -08:00
Eric Anderson a40e4343f5 okhttp: Use normal server cert when testing trust checking
Previously, untrustedServer_fails could have been failing for the same
reason as unmatchedServerSubjectAlternativeNames_fails. The
implementation could have been broken and not checking the cert chain
but still checking the hostname. We'd either need to override the
authority to match the badserver cert or use the normal server
certificates. It is best to use the normal server certificates as
mtls_succeeds confirms the configuration is correct and so our test is
failing for the right reason.
2023-01-09 10:28:35 -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
Eric Anderson c80b587579
okhttp: Add missing server support for TLS ClientAuth (#9711) 2022-11-22 17:09:03 -08:00
yifeizhuang 47ddfa4f20
okhttp: add maxConnectionAge and maxConnectionAgeGrace (#9649) 2022-10-21 12:06:26 -07:00
Terry Wilson dd35ae5206
okhttp: Add client transport proxy socket timeout (#9586)
Not having a timeout when reading the response from a proxy server can
cause a hang if network connectivity is lost at the same time.
2022-10-04 12:43:02 -07:00
yifeizhuang a3c1d7711f
okhttp: add okhttpServerBuilder permitKeepAliveTime() and permitKeepAliveWithoutCalls() for server keepAlive enforcement (#9544) 2022-09-15 16:08:55 -07:00
Terry Wilson 79c4c355ba
okhttp: Fair treatment when writing out streams (#9545)
When allocating bytes to streams within a flow control window we always
go through the streams in the same order. This can lead to large streams
hogging all the bytes and a smaller one down the list getting starved
out. This change shuffles the stream array to lower the chance of this
happening.

Fixes #9089
2022-09-15 09:35:23 -07:00
yifeizhuang eac4178eaa
okhttp: add max connection idle at OkHttpServer and fix test (#9533)
* Revert "Revert "okhttp: add max connection idle at OkHttpServer (#9494)" (#9528)"

This reverts commit 95b9d6db29 and fixed flaky test.
2022-09-09 12:53:47 -07:00
yifeizhuang 95b9d6db29
Revert "okhttp: add max connection idle at OkHttpServer (#9494)" (#9528)
This reverts commit 7291ad44c6.
2022-09-08 08:51:16 -07:00
yifeizhuang 7291ad44c6
okhttp: add max connection idle at OkHttpServer (#9494) 2022-08-29 16:25:58 -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 0e45e04041
Avoid accidental locale-sensitive String.format()
%s is fairly safe (requires a Formattable to use Locale), so %d is the
main risk item. Places that really didn't need to use String.format()
were converted to plain string concatenation. Logging locations were
generally converted to using the log infrastructure's delayed
formatting, which is generally locale-sensitive but we're okay with
that. That wasn't done in okhttp, however, because Android frequently
doesn't use MessageFormat so we'd lose the parameters. Everywhere else
was explicitly defined to be Locale.US, to be consistent independent of
the default system locale.
2022-07-19 14:41:34 -07:00
Eric Anderson 55fd6268c6 Revert "Fix for ipv6 link local with scope (#9326)"
This reverts commit c1abc7f8ac. It
produced compilation issues inside Google. I strongly suspect it isn't
this commit or gRPC's fault, but it prevents further testing until it is
resolved.
2022-07-14 11:41:01 -07:00
Eric Anderson eb25807d43 okhttp: Avoid default locale in String.format() 2022-07-13 11:10:22 -07:00
Sergii Tkachenko fe1cfc9b96
okhttp: Comment out VisibleForTesting annotation (#9352)
Android linters can't recognize the difference when VisibleForTesting
is used because the method has different visibility, or because
the method only intended for testing.

Because of that linter complains when VisibleForTesting methods are
used in the production code.

Ideally we want to replace or remove this annotation, as its
usage for marking altered visibility for testing purposes is
discouraged since guava v30.0.
2022-07-08 18:00:48 -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
Eric Anderson e767905f4a okhttp: Fix AsyncSink.close() NPE
This fixes a regression introduced in e96d0477. The NullPointerException
only happens on client-side when some other error occurred during
handshaking.

I tried to add a test, but SerializingExecutor catches+logs the
exception and the expected behavior in the circumstance is that close()
is a noop. So the NPE was entirely benign other than annoying log
messages.
2022-07-07 07:28:21 -07:00
Jader Alcântara c1abc7f8ac
Fix for ipv6 link local with scope (#9326) 2022-07-07 06:57:04 -07:00
Eric Anderson 2fc7ac441c interop-testing: Add cartesian product HTTP/2 interop test 2022-07-01 12:38:01 -07:00
Eric Anderson 2cb2fe5008 okhttp: Add support for file-based private keys 2022-07-01 12:38:01 -07:00
Eric Anderson bc50adf4b4 okhttp: Limit number of outstanding client-induced control frames 2022-07-01 12:38:01 -07:00
Eric Anderson e96d04774b okhttp: Add server implementation 2022-07-01 12:38:01 -07:00
Eric Anderson fad38f49f1
Fix Channelz window reporting
Both Netty and OkHttp had local and remote windows flipped. Also, the
comment in OkHttp about "not tracked" wasn't true, so make it more
accurate and provide a _hint_ of what the window may be instead of just
-1.
2022-06-27 12:29:57 -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
sanjaypujare 538db03d56
api: add support for SocketAddress types in ManagedChannelProvider (#9076)
* api: add support for SocketAddress types in ManagedChannelProvider
also add support for SocketAddress types in NameResolverProvider
Use scheme in target URI to select a NameRseolverProvider and get
that provider's supported SocketAddress types.
implement selection in ManagedChannelRegistry of appropriate
ManagedChannelProvider based on NameResolver's SocketAddress types
2022-04-22 09:10:55 -07:00
Eric Anderson 592a227686 okhttp: Allow keepalive scheduled executor to be overridden
Users should be able to inject all executors. The transport shouldn't be
hard-coded to create the TIMER_SERVICE, especially since a scheduler is
already available to the builder.
2022-04-15 15:28:58 -07:00
Eric Anderson 8862dca624 okhttp: Use ObjectPool for executors internally in Builder
This matches what we do in ManagedChannelImplBuilder and
NettyChannelBuilder. It also fixes a (probably unimportant) bug where
the factory returned from swapChannelCredentials() didn't have its
references to the executors so could not outlive the parent factory.
2022-04-15 15:28:58 -07:00
Eric Anderson 78ccc81fd5 okhttp: Remove dead code in io.grpc.okhttp.internal.Util
A substantial portion of the methods are unused. While these don't
contribute to the size of Android builds because of dead code
elimination in the build process, they still show up in static analysis
and raise questions like "when are we using MD5" or "when are we special
casing exception message text" (answer: "we're not").
2022-04-08 08:24:35 -07:00
Eric Anderson 054cb49b49
okhttp: Remove RPCs-before-ready tests
In the olden days, before LB policies, transports had to accept RPCs as
soon as they were created. This hasn't been true for a very long time,
so remove the tests.

Since a978c9ed we're using real, legit code flows in the tests. This
allowed TSAN to discover that `attributes` is racy when read when
creating a new stream before the transport is ready. We could use a lock
or volatile, but the value of the attributes would still be incorrect
for any RPCs that are created before the transport is ready.

Since there's now only one test that delays the connection, I inline the
support code.
2022-04-07 13:30:25 -07:00
Eric Anderson 5351fb9c25 okhttp: Pass TransportFactory directly to transport constructor
This greatly reduces the number of arguments passed to the constructor
and allows using the builder in tests to change specific arguments
without having to pass all the other arguments. It also makes it easier
to see where tests are doing something special.

While it is weird to expose fields as package-private for digging-into
in the constructor, it's actually very similar to the pattern of passing
the builder instance into the constuctor. In this case, the weirdness is
because the builder isn't a nested class of the transport and there is
an additional level of building going on (Builder and TransportFactory).
We do this pattern already in ManagedChannelImpl which only has the one
level of building.
2022-04-07 09:07:13 -07:00
Terry Wilson 98e4d49bbb Copybara cleanup. 2022-04-05 11:49:20 -07:00
yifeizhuang 78308c0c6a
okhttp: Fix okio 2.x API incompatibility (#9054) 2022-04-04 17:37:28 -07:00
Eric Anderson 18753b654f okhttp: Add Javadoc for ExceptionHandlingFrameWriter 2022-04-04 13:37:30 -07:00
Eric Anderson a978c9edc0 okhttp: Avoid test-specific transport.start()
With the completely different constructor it was hard to track which
fields were different during the test and reduced confidence. Now the
test code flows are much closer to the real-life code flows.
2022-04-04 11:48:14 -07:00
yifeizhuang db36905abf
okhttp: fix unreported exception (#9044) 2022-04-01 14:38:37 -07:00
beatrausch b20ce17817
okhttp: make okhttp dependencies compile only (#8971)
* okhttp: forked required files to make okhttp dep compile only

* okhttp: forked missing file to make okhttp dep compile only

* okhttp: moved url and request files to proxy packge

* okhttp: removed unused methods from forked files; fixed build
2022-03-30 13:43:30 -07:00
ZHANG Dapeng 560a7fb084
okhttp: local-only transparent retry for okhttp
The OKHttp counterpart for #8878.
2022-02-11 13:02:23 -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
Penn (Dapeng) Zhang 3179bc3be0 Revert "use charset from StandardCharsets instead of 'Charset.forName' (#8779)"
This reverts commit a74a3ad834.
2022-01-18 10:14:50 -08:00
Jintao a74a3ad834
use charset from StandardCharsets instead of 'Charset.forName' (#8779)
Co-authored-by: Penn (Dapeng) Zhang <zdapeng@google.com>
2022-01-07 15:03:14 -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
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
beatrausch 5a3b8e2141
okhttp: introduced new TLS1.2 cipher suites and internal okhttp implementation for TLS1.3 prepared (#8650)
This introduces new TLS 1.2 cipher suites (#8610) and prepares the
internal okhttp implementation for TLS1.3. A new method for creating
internal ConnectionSpec was added to be able to use the newly introduced
cipher suites in the OkHttpChannelBuilder. Okhttp cipher suites
synchronized with the ones from netty.
2021-11-16 18:29:29 -08:00
Sergii Tkachenko 0376de15b8
Fix AbstractManagedChannelImplBuilder#maxInboundMessageSize(int) ABI (#8607)
In refactoring described in #7211, the implementation of #maxInboundMessageSize(int)
(and its corresponding field) were pulled down from internal AbstractManagedChannelImplBuilder
to concrete classes that actually enforce this setting. For the same reason, it wasn't ported
to ManagedChannelImplBuilder (the #delegate()).

Then AbstractManagedChannelImplBuilder was brought back to fix ABI backward compatibility,
and temporarily turned into a ForwardingChannelBuilder, ref PR #7564. Eventually it will
be deleted, after a period with "bridge" ABI solution introduced in #7834.

However, restoring AbstractManagedChannelImplBuilder unintentionally made ABI of
pre-refactoring builds expect it to be a method of AbstractManagedChannelImplBuilder,
and not concrete classes, ref #8313.

The end goal is to keep #maxInboundMessageSize(int) only in concrete classes that enforce it.
To fix method's ABI, we temporary reintroduce it to the original layer it was removed from:
AbstractManagedChannelImplBuilder. This class' only intention is to provide short-term
ABI compatibility. Once we move forward with dropping the ABI, both fixes are no longer
necessary, and both will perish with removing AbstractManagedChannelImplBuilder.
2021-10-14 17:25:06 -07:00
ZHANG Dapeng 860e97d12a
all: API refactoring in preparation to support retry stats (#8355)
Rebased PR #8343 into the first commit of this PR, then (the 2nd commit) reverted the part for metric recording of retry attempts. The PR as a whole is mechanical refactoring. No behavior change (except that some of the old code path when tracer is created is moved into the new method `streamCreated()`).

The API change is documented in go/grpc-stats-api-change-for-retry-java
2021-07-31 18:33:02 -07:00