From aeff192ee98b791ffeb1ae7671bd0ccb6d7d8d2e Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Mon, 2 Sep 2024 09:00:25 +0200 Subject: [PATCH] Rename ConnectionBase#getContext() -> ConnectionBase#context() --- .../core/http/impl/Http2UpgradeClientConnection.java | 2 +- .../vertx/core/http/impl/HttpChannelConnector.java | 2 +- .../java/io/vertx/core/http/impl/HttpNetSocket.java | 2 +- .../core/http/impl/ServerWebSocketHandshaker.java | 4 ++-- .../io/vertx/core/http/impl/VertxHttp2Stream.java | 12 ++++++------ .../java/io/vertx/core/internal/ContextInternal.java | 8 -------- .../java/io/vertx/core/net/impl/ConnectionBase.java | 2 +- 7 files changed, 12 insertions(+), 20 deletions(-) diff --git a/vertx-core/src/main/java/io/vertx/core/http/impl/Http2UpgradeClientConnection.java b/vertx-core/src/main/java/io/vertx/core/http/impl/Http2UpgradeClientConnection.java index b2cec15710f..bb7bc7bfd4f 100644 --- a/vertx-core/src/main/java/io/vertx/core/http/impl/Http2UpgradeClientConnection.java +++ b/vertx-core/src/main/java/io/vertx/core/http/impl/Http2UpgradeClientConnection.java @@ -358,7 +358,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception public void upgradeTo(ChannelHandlerContext ctx, FullHttpResponse upgradeResponse) throws Exception { // Now we need to upgrade this to an HTTP2 - VertxHttp2ConnectionHandler handler = Http2ClientConnection.createHttp2ConnectionHandler(upgradedConnection.client, upgradingConnection.metrics, upgradingConnection.getContext(), true, upgradedConnection.current.metric(), upgradedConnection.current.authority(), upgradingConnection.pooled()); + VertxHttp2ConnectionHandler handler = Http2ClientConnection.createHttp2ConnectionHandler(upgradedConnection.client, upgradingConnection.metrics, upgradingConnection.context(), true, upgradedConnection.current.metric(), upgradedConnection.current.authority(), upgradingConnection.pooled()); upgradingConnection.channel().pipeline().addLast(handler); handler.connectFuture().addListener(future -> { if (!future.isSuccess()) { diff --git a/vertx-core/src/main/java/io/vertx/core/http/impl/HttpChannelConnector.java b/vertx-core/src/main/java/io/vertx/core/http/impl/HttpChannelConnector.java index b31054d93a3..270e3710733 100644 --- a/vertx-core/src/main/java/io/vertx/core/http/impl/HttpChannelConnector.java +++ b/vertx-core/src/main/java/io/vertx/core/http/impl/HttpChannelConnector.java @@ -227,7 +227,7 @@ private void http1xConnected(HttpVersion version, conn2.concurrencyChangeHandler(concurrency -> { // Ignore }); - conn2.createStream(conn.getContext()).onComplete(ar -> { + conn2.createStream(conn.context()).onComplete(ar -> { if (ar.succeeded()) { HttpClientStream stream = ar.result(); stream.headHandler(resp -> { diff --git a/vertx-core/src/main/java/io/vertx/core/http/impl/HttpNetSocket.java b/vertx-core/src/main/java/io/vertx/core/http/impl/HttpNetSocket.java index 955eda86e0f..edd281332b6 100644 --- a/vertx-core/src/main/java/io/vertx/core/http/impl/HttpNetSocket.java +++ b/vertx-core/src/main/java/io/vertx/core/http/impl/HttpNetSocket.java @@ -194,7 +194,7 @@ public Future end() { @Override public Future sendFile(String filename, long offset, long length) { - return HttpUtils.resolveFile(conn.getContext(), filename, offset, length) + return HttpUtils.resolveFile(conn.context(), filename, offset, length) .compose(file -> file .pipe() .endOnComplete(false) diff --git a/vertx-core/src/main/java/io/vertx/core/http/impl/ServerWebSocketHandshaker.java b/vertx-core/src/main/java/io/vertx/core/http/impl/ServerWebSocketHandshaker.java index b5240ef9f4c..0af80bf3b4f 100644 --- a/vertx-core/src/main/java/io/vertx/core/http/impl/ServerWebSocketHandshaker.java +++ b/vertx-core/src/main/java/io/vertx/core/http/impl/ServerWebSocketHandshaker.java @@ -505,7 +505,7 @@ private ServerWebSocket acceptHandshake() { return webSocketConn; }); CompletableFuture latch = new CompletableFuture<>(); - httpConn.getContext().execute(() -> { + httpConn.context().execute(() -> { // Must be done on event-loop pipeline.replace(VertxHandler.class, "handler", handler); latch.complete(null); @@ -520,7 +520,7 @@ private ServerWebSocket acceptHandshake() { if (METRICS_ENABLED && httpConn.metrics != null) { webSocket.setMetric(httpConn.metrics.connected(httpConn.metric(), requestMetric, this)); } - webSocket.registerHandler(httpConn.getContext().owner().eventBus()); + webSocket.registerHandler(httpConn.context().owner().eventBus()); return webSocket; } } diff --git a/vertx-core/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java b/vertx-core/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java index ee4629e7049..a97caaa80e4 100644 --- a/vertx-core/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java +++ b/vertx-core/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java @@ -65,7 +65,7 @@ protected void handleMessage(Object item) { } else { Buffer data = (Buffer) item; int len = data.length(); - conn.getContext().emit(null, v -> { + conn.context().emit(null, v -> { if (stream.state().remoteSideOpen()) { // Handle the HTTP upgrade case // buffers are received by HTTP/1 and not accounted by HTTP/2 @@ -79,7 +79,7 @@ protected void handleMessage(Object item) { this.priority = HttpUtils.DEFAULT_STREAM_PRIORITY; this.isConnect = false; this.writable = true; - this.outboundQueue = new OutboundMessageQueue<>(conn.getContext().nettyEventLoop()) { + this.outboundQueue = new OutboundMessageQueue<>(conn.context().nettyEventLoop()) { // TODO implement stop drain to optimize flushes ? @Override public boolean test(MessageWrite msg) { @@ -200,7 +200,7 @@ public boolean isNotWritable() { public final Future writeFrame(int type, int flags, ByteBuf payload) { Promise promise = context.promise(); - EventLoop eventLoop = conn.getContext().nettyEventLoop(); + EventLoop eventLoop = conn.context().nettyEventLoop(); if (eventLoop.inEventLoop()) { doWriteFrame(type, flags, payload, promise); } else { @@ -210,7 +210,7 @@ public final Future writeFrame(int type, int flags, ByteBuf payload) { } public final void writeFrame(int type, int flags, ByteBuf payload, Promise promise) { - EventLoop eventLoop = conn.getContext().nettyEventLoop(); + EventLoop eventLoop = conn.context().nettyEventLoop(); if (eventLoop.inEventLoop()) { doWriteFrame(type, flags, payload, promise); } else { @@ -224,7 +224,7 @@ private void doWriteFrame(int type, int flags, ByteBuf payload, Promise pr final void writeHeaders(Http2Headers headers, boolean first, boolean end, boolean checkFlush, Promise promise) { if (first) { - EventLoop eventLoop = conn.getContext().nettyEventLoop(); + EventLoop eventLoop = conn.context().nettyEventLoop(); if (eventLoop.inEventLoop()) { doWriteHeaders(headers, end, checkFlush, promise); } else { @@ -288,7 +288,7 @@ void doWriteData(ByteBuf buf, boolean end, Promise promise) { } final void writeReset(long code) { - EventLoop eventLoop = conn.getContext().nettyEventLoop(); + EventLoop eventLoop = conn.context().nettyEventLoop(); if (eventLoop.inEventLoop()) { doWriteReset(code); } else { diff --git a/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java b/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java index 7a2358f7d0d..806ef017e86 100644 --- a/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java +++ b/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java @@ -54,14 +54,6 @@ default void runOnContext(Handler action) { */ EventExecutor executor(); - default ContextInternal asEventLoopContext() { - if (threadingModel() == ThreadingModel.EVENT_LOOP) { - return this; - } else { - return owner().createEventLoopContext(nettyEventLoop(), workerPool(), classLoader()); - } - } - /** * Return the Netty EventLoop used by this Context. This can be used to integrate * a Netty Server with a Vert.x runtime, specially the Context part. diff --git a/vertx-core/src/main/java/io/vertx/core/net/impl/ConnectionBase.java b/vertx-core/src/main/java/io/vertx/core/net/impl/ConnectionBase.java index 4f47fba0177..5910b5ebb9c 100644 --- a/vertx-core/src/main/java/io/vertx/core/net/impl/ConnectionBase.java +++ b/vertx-core/src/main/java/io/vertx/core/net/impl/ConnectionBase.java @@ -235,7 +235,7 @@ public final ChannelHandlerContext channelHandlerContext() { return chctx; } - public final ContextInternal getContext() { + public final ContextInternal context() { return context; }