grpc-java/core/src
Chris Povirk 6bafca93a7
core: Use real ByteBuffer instead of mock (#9523)
My motivation for making this change is that [`ByteBuffer` is becoming
`sealed`](https://download.java.net/java/early_access/loom/docs/api/java.base/java/nio/ByteBuffer.html)
in new versions of Java. This makes it impossible for Mockito's
_current_ default mockmaker to mock it.

That said, Mockito will likely [switch its default
mockmaker](https://github.com/mockito/mockito/issues/2589) to an
alternative that _is_ able to mock `sealed` classes. However, there are
downside to that, such as [slower
performance](https://github.com/mockito/mockito/issues/2589#issuecomment-1192725206),
so it's probably better to leave our options open by avoiding mocking at
all.

And in this case, it's equally easy to use real objects.

As a bonus, I think that real objects makes the code a little easier to
follow: Before, we created mocks that the code under test never
interacted with in any way. (The code just passed them through to a
delegate.) When I first read the tests, I was confused, since I assumed
that the mock we were creating was the same mock that we then passed to
`verify` at the end of the method. That turned out not to be the case.
2022-09-07 15:50:31 -07:00
..
bazel-internal/resources/META-INF/services core: fix bazel NameResolverProvider not found 2018-12-05 09:45:41 -08:00
bazel-util/resources/META-INF/services core: fix bazel NameResolverProvider not found 2018-12-05 09:45:41 -08:00
jmh/java/io/grpc all: API refactoring in preparation to support retry stats (#8355) 2021-07-31 18:33:02 -07:00
main core: Don't forward acceptResolvedAddresses() (#9511) 2022-09-06 13:06:48 -07:00
test core: Use real ByteBuffer instead of mock (#9523) 2022-09-07 15:50:31 -07:00