GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make half-closure a core-concept of Channel by normanmaurer · Pull Request #15987 · netty/netty

Make half-closure a core-concept of Channel #15987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
normanmaurer merged 4 commits into 5.0 from shutdown_core
Dec 10, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

Make half-closure a core-concept of Channel #15987

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
46b7177
Make half-closure a core-concept of Channel (#12468)
normanmaurer Dec 4, 2025
1bb3947
Fix epoll and io_uring half closure
normanmaurer Dec 9, 2025
7444c49
Add comments
normanmaurer Dec 9, 2025
3a0dcaa
Update state before notify promise to fix race
normanmaurer Dec 10, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

13 changes: 8 additions & 5 deletions 13 codec-base/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.socket.ChannelInputShutdownEvent;
import io.netty.channel.ChannelShutdownDirection;
import io.netty.channel.ChannelShutdownType;
import io.netty.util.IllegalReferenceCountException;
import io.netty.util.internal.ObjectUtil;
import io.netty.util.internal.StringUtil;
Expand Down Expand Up @@ -393,14 +394,16 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
}

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof ChannelInputShutdownEvent) {
public void channelShutdown(ChannelHandlerContext ctx, ChannelShutdownType type)
throws Exception {
if (type.direction() == ChannelShutdownDirection.Inbound) {
// The decodeLast method is invoked when a channelInactive event is encountered.
// This method is responsible for ending requests in some situations and must be called
// when the input has been shutdown.
channelInputClosed(ctx, false);
}
super.userEventTriggered(ctx, evt);

super.channelShutdown(ctx, type);
}

private void channelInputClosed(ChannelHandlerContext ctx, boolean callChannelInactive) {
Expand Down Expand Up @@ -435,7 +438,7 @@ private void channelInputClosed(ChannelHandlerContext ctx, boolean callChannelIn

/**
* Called when the input of the channel was closed which may be because it changed to inactive or because of
* {@link ChannelInputShutdownEvent}.
* {@link #channelShutdown(ChannelHandlerContext, ChannelShutdownType}.
*/
void channelInputClosed(ChannelHandlerContext ctx, List<Object> out) throws Exception {
if (cumulation != null) {
Expand Down
4 changes: 2 additions & 2 deletions 4 codec-base/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelShutdownType;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.channel.socket.ChannelInputShutdownEvent;
import io.netty.util.CharsetUtil;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -567,7 +567,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
assertNull(channel.readInbound());
removeHandler.set(true);
// This should trigger channelInputClosed(...)
channel.pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
channel.pipeline().fireChannelShutdown(ChannelShutdownType.newInbound());

assertTrue(channel.finish());
assertBuffer(Unpooled.wrappedBuffer(bytes), (ByteBuf) channel.readInbound());
Expand Down
4 changes: 2 additions & 2 deletions 4 codec-base/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelShutdownType;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.channel.socket.ChannelInputShutdownEvent;
import org.junit.jupiter.api.Test;

import java.util.List;
Expand Down Expand Up @@ -282,7 +282,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
});

assertFalse(channel.writeInbound(Unpooled.wrappedBuffer(new byte[] {0, 1})));
channel.pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
channel.pipeline().fireChannelShutdown(ChannelShutdownType.newInbound());
assertFalse(channel.finishAndReleaseAll());

Error err = error.get();
Expand Down
102 changes: 7 additions & 95 deletions 102 codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicStreamChannel.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*/
package io.netty.handler.codec.quic;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPromise;
import io.netty.channel.socket.DuplexChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.ChannelShutdownType;
import org.jetbrains.annotations.Nullable;

import java.net.SocketAddress;

/**
* A QUIC stream {@link DuplexChannel}.
* A QUIC stream {@link Channel}.
*
* <h3>Available options</h3>
*
* In addition to the options supported by {@link DuplexChannel},
* In addition to the options supported by {@link Channel},
* {@link QuicStreamChannel} allows the following options in the
* option map via {@link io.netty.channel.ChannelOption}:
*
Expand All @@ -41,13 +41,14 @@
* </tr>
* </table>
*/
public interface QuicStreamChannel extends DuplexChannel {
public interface QuicStreamChannel extends Channel {

/**
* Should be added to a {@link ChannelFuture} when the output should be cleanly shutdown via a {@code FIN}. No more
* writes will be allowed after this point.
*/
ChannelFutureListener SHUTDOWN_OUTPUT = f -> ((QuicStreamChannel) f.channel()).shutdownOutput();
ChannelFutureListener SHUTDOWN_OUTPUT = f ->
f.channel().shutdown(ChannelShutdownType.newOutbound());

@Override
default ChannelFuture bind(SocketAddress socketAddress) {
Expand Down Expand Up @@ -145,95 +146,6 @@ default ChannelFuture newFailedFuture(Throwable cause) {
return pipeline().newFailedFuture(cause);
}

@Override
default ChannelFuture shutdownInput() {
return shutdownInput(newPromise());
}

@Override
default ChannelFuture shutdownInput(ChannelPromise promise) {
return shutdownInput(0, promise);
}

@Override
default ChannelFuture shutdownOutput() {
return shutdownOutput(newPromise());
}

@Override
default ChannelFuture shutdown() {
return shutdown(newPromise());
}

/**
* Shortcut for calling {@link #shutdownInput(int)} and {@link #shutdownInput(int)}.
*
* @param error the error to send.
* @return the future that is notified on completion.
*/
default ChannelFuture shutdown(int error) {
return shutdown(error, newPromise());
}

/**
* Shortcut for calling {@link #shutdownInput(int, ChannelPromise)} and {@link #shutdownInput(int, ChannelPromise)}.
*
* @param error the error to send.
* @param promise will be notified on completion.
* @return the future that is notified on completion.
*/
ChannelFuture shutdown(int error, ChannelPromise promise);

/**
* Shutdown the input of the stream with the given error code. This means a {@code STOP_SENDING} frame will
* be send to the remote peer and all data received will be discarded.
*
* @param error the error to send as part of the {@code STOP_SENDING} frame.
* @return the future that is notified on completion.
*/
default ChannelFuture shutdownInput(int error) {
return shutdownInput(error, newPromise());
}

/**
* Shutdown the input of the stream with the given error code. This means a {@code STOP_SENDING} frame will
* be send to the remote peer and all data received will be discarded.
*
* @param error the error to send as part of the {@code STOP_SENDING} frame.
* @param promise will be notified on completion.
* @return the future that is notified on completion.
*/
ChannelFuture shutdownInput(int error, ChannelPromise promise);

/**
* Shutdown the output of the stream with the given error code. This means a {@code RESET_STREAM} frame will
* be send to the remote peer and all data that is not sent yet will be discarded.
*
* <strong>Important:</strong>If you want to shutdown the output without sending a {@code RESET_STREAM} frame you
* should use {@link #shutdownOutput()} which will shutdown the output by sending a {@code FIN} and so signal
* a clean shutdown.
*
* @param error the error to send as part of the {@code RESET_STREAM} frame.
* @return the future that is notified on completion.
*/
default ChannelFuture shutdownOutput(int error) {
return shutdownOutput(error, newPromise());
}

/**
* Shutdown the output of the stream with the given error code. This means a {@code RESET_STREAM} frame will
* be send to the remote peer and all data that is not sent yet will be discarded.
*
* <strong>Important:</strong>If you want to shutdown the output without sending a {@code RESET_STREAM} frame you
* should use {@link #shutdownOutput(ChannelPromise)} which will shutdown the output by sending a {@code FIN}
* and so signal a clean shutdown.
*
* @param error the error to send as part of the {@code RESET_STREAM} frame.
* @param promise will be notified on completion.
* @return the future that is notified on completion.
*/
ChannelFuture shutdownOutput(int error, ChannelPromise promise);

@Override
QuicStreamAddress localAddress();

Expand Down
6 changes: 6 additions & 0 deletions 6 codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicChannel.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.channel.ChannelShutdownType;
import io.netty.channel.RecvByteBufAllocator;
import io.netty.channel.socket.DatagramPacket;
import io.netty.handler.ssl.SniCompletionEvent;
Expand Down Expand Up @@ -240,6 +241,11 @@ private static long[] growIfNeeded(long[] array, int maxLength) {
return array;
}

@Override
protected void doShutdown(ChannelShutdownType type, ChannelPromise promise) {
promise.setFailure(new UnsupportedOperationException());
}

@Override
public boolean isTimedOut() {
return timedOut;
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.