Commit Graph

75 Commits

Author SHA1 Message Date
Chengyuan Zhang 2734e22ef5
context, stub: check result of CountDownLatch.await() in test (#6664) 2020-01-31 15:03:22 -08:00
Nathan H. Leung 9c9163d453 context: update javadoc for withValue(s) to indicate withValue can be chained (#6545) 2019-12-18 13:33:31 -08: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
Eric Anderson 55ac6f08af Apply JMH plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Aaditya Gavandalkar 39dc883b34 context: Implement equals and hashCode for Deadline (grpc#6075) 2019-08-30 08:25:07 -07:00
ZHANG Dapeng 92805713e4
doc: explicitly mention that Deadline might saturate 2019-08-20 14:28:45 -07:00
Kun Zhang 4e4d4d8ab5
core: allow setting custom Deadline.Ticker to InProcessServerBuilder (#6034)
ServerImpl uses that ticker to create incoming Deadlines. This feature is specifically restricted to in-process, as it can also customize ScheduledExecutorService, and them together can fake out the clock which is useful in tests. On the other hand, a fake Ticker won't work with Netty's ScheduledExecutorService.

Also improved mismatch detection, documentation and tests in Deadline.
2019-08-01 13:13:20 -07:00
Kun Zhang f9509694b9
context: allow creating Deadline with custom Ticker. (#6031)
This makes Deadline more test-friendly. Next step is to allow
ServerBuilder to take a custom Ticker and use it for creating
incoming Deadlines. With both changes in, application logic will be
able to verify the Deadlines they set.
2019-07-31 11:26:51 -07:00
Carl Mastrangelo 8a9afd618a
context: fix race between CancellableContext and Context
The `pendingDeadline` variable is modified from the ctor of CancellableContext, but it isn't final.  The cancellation can happen before the variable is assigned.  It's generally bad practice to leak the this reference from the ctor to other threads anyways.

This code refactors the deadline calculation and scheduling so that `pendingDeadline` is modified under the lock, and the `this` reference is not exposed.

Discovered by TSAN.
2019-07-17 01:12:21 -07:00
Carl Mastrangelo dcd68e5b57
context: Extend raw ComparableSubject instead of supplying type parameters 2019-06-06 15:00:03 -07:00
Carl Mastrangelo 7657523b28
all: update to error prone 2.3.3 2019-06-05 15:28:43 -07:00
Carl Mastrangelo 409afe5867
all: update to truth 0.45 2019-06-04 21:12:21 -07:00
Carl Mastrangelo 0a13104f4a
context: drop call to actual() in DeadlineSubject 2019-05-07 14:09:26 -07:00
Carl Mastrangelo 04e07034f3
all: update to truth 0.44 2019-04-23 10:50:49 -07:00
Carl Mastrangelo 8941a69480
context: avoid synthetic methods on Context 2019-04-16 09:02:05 -07:00
Eric Anderson 5b2187d6bd context: Remove unnecessary deps from Bazel target 2019-04-12 19:18:44 -07:00
Carl Mastrangelo 75bc066cab
context: try out static final storage 2019-04-09 20:33:40 -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 3a39b81cf5
all: remove java6 type args 2019-02-04 10:03:50 -08:00
Eric Anderson 4a3f28f45f context: fix detaching ROOT
If you attach literal ROOT to the thread, if anyone else restores root
it will set the thread local to be null. This broke the "are you
detaching the current context" check, as ROOT != null. This was a
regression introduced in 55b08e67d.
2019-02-01 11:56:20 -08:00
ZHANG Dapeng d0ecc08705
all: fix lint 2019-01-31 09:31:13 -08:00
Eric Anderson 55b08e67d4 context: Avoid leaking ClassLoader through ThreadLocal 2019-01-28 13:54:52 -08:00
Carl Mastrangelo 2d654496ee
context: make Deadline toString() more readable 2018-12-05 17:44:44 -08:00
Rodrigo Queiro 8481943866 Add missing j2objc dependency to Bazel build
This avoids a warning when building artifacts that depend on Guava.

Fixes #5046.
2018-11-13 13:39:35 -08:00
Carl Mastrangelo b0f423295b
all: use Java7 brackets 2018-09-14 13:52:29 -07:00
Eric Gribkoff 79b24709b9
all: update animalsniffer to Java 7 and add Android 14 (#4727) 2018-08-09 09:09:21 -07:00
Eric Anderson 6d7c7dc583 context: Avoid deprecated Truth API
This helps an internal cleanup removing the old failWithRawMessage API.
2018-07-20 14:48:44 -07:00
ZHANG Dapeng bf4a00c6de
context/core/netty: Add @CheckReturnValue to Context
By adding inner class annotations without introducing external dependencies.
2018-05-15 13:14:30 -07:00
Carl Mastrangelo 60a0b0c471
all: normalize copyright header 2018-05-03 14:55:21 -07:00
Carl Mastrangelo a414b91a59
context: remove context profiling 2018-02-15 18:08:19 -08:00
Carl Mastrangelo 6ea8fffa2b
context: add basic context profiling 2018-02-09 19:45:19 -08:00
Bogdan Drutu af936919f3 Update opencensus to 0.11.0 and remove extra dependencies. 2018-01-26 13:04:26 -08:00
Eric Anderson 2d88269965 Update to Truth 0.36
Due to transitive dependencies, this also upgrades Guava to 22. However
Truth is only used in our tests, so our users should be unimpacted.
2017-12-04 13:48:00 -08:00
Eric Anderson 2bde25d2d9 testing: Remove DeadlineSubject
The class is still used internally, so we move it to context's tests for
it to be reused. To avoid a circular dependency with context's tests
depending on core's tests, StaticTestingClassLoader was also moved to
context's tests.

This is driven by a need to modernize DeadlineSubject for newer versions
of Truth, but the newer versions of Truth update Guava. To avoid leaking
the Guava update to all users of grpc-testing, we're removing the
Subject. In our internal tests we can update the Truth dependency with
less issue.
2017-11-22 17:57:46 -08:00
zpencer 255643bed9 context: Make CancellableContext implement Closeable (#3607) 2017-10-25 11:17:44 -07:00
Eric Anderson 5bf4f5b7a6 context: Use .class literal instead of Class.forName
Found via ErrorProne
2017-09-20 09:43:50 -07:00
Eric Anderson bd28b92850 Avoid catching AssertionError in tests
Found via ErrorProne
2017-09-20 09:43:50 -07:00
zpencer 86dec11f7b context: log severe warning if ancestry chain too long (#3459)
If a context has an unreasonable number of ancestors, then
chances are this is an application error. Log the stack trace to
notify the user and aid in debugging.
2017-09-14 11:39:19 -07:00
Eric Anderson 6164b7b2ee Move jmh benchmarks to their respective modules
The benchmarks should be close to the code they're benchmarking, like
we do with tests.

This includes a bugfix to SerializingExecutorBenchmark to let it run.

The io.grpc.benchmarks.netty benchmarks in benchmarks/ depend on
ByteBufOutputMarshaller from benchmarks's main, so they were not moved.
2017-08-28 13:37:39 -07:00
Eric Gribkoff 812e65a5ca context: add RunWith annotation 2017-08-28 12:11:02 -07:00
Eric Anderson 3620931eae context: Use polymorphism instead of canBeCancelled field 2017-08-28 09:41:56 -07:00
Eric Anderson 21cd244734 context: Remove superfluous cascadesCancellation field 2017-08-28 09:41:56 -07:00
Eric Anderson 7cafb6745b context: Store Deadline in CancellableContext directly 2017-08-24 13:21:06 -07:00
zpencer e707d95d77 context: compress cancellation ancestor chain (#3372)
Now that we have the copy of write keyvalue store (#3368), there
is no need to keep the full parent chain. We only need a
reference to the nearest cancellable ancestor. This optimization
should in theory make cancellations more efficient and also make
our data structs more GC friendly.
2017-08-22 09:20:31 -07:00
zpencer 608b95547b context: remove unused fields from removed bloomfilter (#3371)
remove unused fields from removed bloom filter
2017-08-22 08:21:31 -07:00
zpencer b45e354411 context: hashtrie based keyvalue store (#3368)
This is the hashtrie data structure authored by @ejona86

The linked list key value store is known cause problems in
pathological cases where users keep updating the same key(s) over and
over. This copy on write tree will bound reads at O(lgN) where N is
the number of keys in the map, rather than O(lgM) where M is the total
number of put operations.

Also:

- added some unit tests
- ran a test putting random keys into the map and comparing the result
  with a java.util.HashMap to verify sanity. The test passes but I
  won't check it into the repo because it takes a long time to run:
  https://gist.github.com/zpencer/12cb435235d171c1fe09aef18825fad0
2017-08-21 16:35:17 -07:00
zpencer 47ce000464 add bloom filter to Context (#3350)
* This is the bloom filter based context improvement authored by @lukesandberg
2017-08-16 10:38:02 -07:00