Skip to content

Commit

Permalink
Implement netty client using the new micronaut-core RawHttpClient (#989)
Browse files Browse the repository at this point in the history
* Implement netty client using the new micronaut-core RawHttpClient
This PR replaces most of the netty-based HTTP client that previously used the low-level micronaut-http-client ConnectionManager API with an implementation based on the new micronaut-http-client-core RawHttpClient introduced in micronaut-core 4.7.0. This offers some advantages:

- Much simpler implementation. Once the legacy implementation is not needed anymore, all classes deprecated in this PR can be removed.
- Possibility to work with non-netty RawHttpClient implementations, once those exist. In particular, this will allow using the JDK http client instead.
- RawHttpClient runs normal micronaut-core ClientFilters, so we won't need the `OciNettyClientFilter` API anymore.

While in theory the new implementation should be a drop-in replacement, it is possible that RawHttpClient differs slightly in behavior. For that reason, I've kept the old implementation around. It can be enabled by the `oci.netty.legacy-netty-client` config property, or the `io.micronaut.oraclecloud.httpclient.netty.legacy-netty-client` system property.

This also means that MicronautHttpRequest and MicronautHttpResponse are actually mostly copied from NettyHttpRequest and NettyHttpResponse. Please consider that when reviewing, the actual changes are not that big.

This PR works and is ready for review, but still needs a release of micronaut-core 4.7.0 (and of micronaut-serialization due to the unrelated micronaut-projects/micronaut-serialization#943 ).

* review

* small changes

* fix test

* try fixing test

* trigger build

---------

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>
  • Loading branch information
yawkat and sdelamo authored Nov 8, 2024
1 parent ca73bab commit dd114b6
Show file tree
Hide file tree
Showing 29 changed files with 864 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* {@link io.netty.handler.codec.http.LastHttpContent} is received completes a {@link #future} with
* the accumulated data.
*/
@Deprecated
final class BufferFutureHandler extends DecidedBodyHandler {
final CompletableFuture<ByteBuf> future = new CompletableFuture<>();
private CompositeByteBuf buffer;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* consume the body. First any data buffered by {@link UndecidedBodyHandler} is processed, then a {@link HandlerImpl}
* is added to the pipeline to directly process the remaining chunks.
*/
@Deprecated
abstract class DecidedBodyHandler {
private boolean done = false;
private volatile ChannelHandlerContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/**
* Handler that discards incoming data.
*/
@Deprecated
final class DiscardingHandler extends DecidedBodyHandler {
static final DiscardingHandler INSTANCE = new DiscardingHandler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
/**
* {@link java.util.Map} wrapper around netty {@link HttpHeaders}. Read-only.
*/
@Deprecated
final class HeaderMap extends AbstractMap<String, List<String>> {
private final HttpHeaders headers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Handler that buffers some response bytes until a set limit. This way, when normal body reading fails, we can still
* read a potentially short error message from this handler.
*/
@Deprecated
final class LimitedBufferingBodyHandler extends ChannelInboundHandlerAdapter {
private final int maxBuffer;
private CompositeByteBuf buffer;
Expand Down
Loading

0 comments on commit dd114b6

Please sign in to comment.