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 — API: Change method signature to return void when promise is given by normanmaurer · Pull Request #16051 · netty/netty

API: Change method signature to return void when promise is given #16051

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 2 commits into 5.0 from method_no_return
Dec 19, 2025

Uh oh!

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

Merged

API: Change method signature to return void when promise is given #16051

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
f1c08b7
API: Change method signature to return void when promise is given
normanmaurer Dec 15, 2025
5171fbd
Address comments
normanmaurer Dec 19, 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

52 changes: 28 additions & 24 deletions 52 codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicChannel.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,23 @@ public interface QuicChannel extends Channel {
* @return the {@link Future} that will be notified once the operation completes.
*/
default Future<QuicStreamChannel> createStream(QuicStreamType type, @Nullable ChannelHandler handler) {
return createStream(type, handler, executor().newPromise());
Promise<QuicStreamChannel> promise = executor().newPromise();
createStream(type, handler, promise);
return promise;
}

/**
* Creates a stream that is using this {@link QuicChannel} and notifies the {@link Promise} once done.
* The {@link ChannelHandler} (if not {@code null}) is added to the {@link io.netty.channel.ChannelPipeline} of the
* {@link QuicStreamChannel} automatically.
*
* @param type the {@link QuicStreamType} of the {@link QuicStreamChannel}.
* @param handler the {@link ChannelHandler} that will be added to the {@link QuicStreamChannel}s
* {@link io.netty.channel.ChannelPipeline} during the stream creation.
* @param promise the {@link Promise} that will be notified once the operation completes.
* @return the {@link Future} that will be notified once the operation completes.
* @param type the {@link QuicStreamType} of the {@link QuicStreamChannel}.
* @param handler the {@link ChannelHandler} that will be added to the {@link QuicStreamChannel}s
* {@link io.netty.channel.ChannelPipeline} during the stream creation.
* @param promise the {@link Promise} that will be notified once the operation completes.
*/
Future<QuicStreamChannel> createStream(QuicStreamType type, @Nullable ChannelHandler handler,
Promise<QuicStreamChannel> promise);
void createStream(QuicStreamType type, @Nullable ChannelHandler handler,
Promise<QuicStreamChannel> promise);

/**
* Returns a new {@link QuicStreamChannelBootstrap} which makes it easy to bootstrap new {@link QuicStreamChannel}s
Expand All @@ -182,54 +183,57 @@ default QuicStreamChannelBootstrap newStreamBootstrap() {
* @return the future that is notified.
*/
default Future<Void> close(boolean applicationClose, int error, ByteBuf reason) {
return close(applicationClose, error, reason, newPromise());
Promise<Void> promise = newPromise();
close(applicationClose, error, reason, promise);
return promise;
}

/**
* Close the {@link QuicChannel}
*
* @param applicationClose {@code true} if an application close should be used,
* {@code false} if a normal close should be used.
* @param error the application error number, or {@code 0} if no special error should be signaled.
* @param reason the reason for the closure (which may be an empty {@link ByteBuf}.
* @param promise the {@link Promise} that will be notified.
* @return the future that is notified.
* @param applicationClose {@code true} if an application close should be used,
* {@code false} if a normal close should be used.
* @param error the application error number, or {@code 0} if no special error should be signaled.
* @param reason the reason for the closure (which may be an empty {@link ByteBuf}.
* @param promise the {@link Promise} that will be notified.
*/
Future<Void> close(boolean applicationClose, int error, ByteBuf reason, Promise<Void> promise);
void close(boolean applicationClose, int error, ByteBuf reason, Promise<Void> promise);

/**
* Collects statistics about the connection and notifies the {@link Future} once done.
*
* @return the {@link Future} that is notified once the stats were collected.
*/
default Future<QuicConnectionStats> collectStats() {
return collectStats(executor().newPromise());
Promise<QuicConnectionStats> promise = executor().newPromise();
collectStats(promise);
return promise;
}

/**
* Collects statistics about the connection and notifies the {@link Promise} once done.
*
* @param promise the {@link Promise} that is notified once the stats were collected.
* @return the {@link Future} that is notified once the stats were collected.
* @param promise the {@link Promise} that is notified once the stats were collected.
*/
Future<QuicConnectionStats> collectStats(Promise<QuicConnectionStats> promise);
void collectStats(Promise<QuicConnectionStats> promise);

/**
* Collects statistics about the path of the connection and notifies the {@link Future} once done.
*
* @return the {@link Future} that is notified once the stats were collected.
*/
default Future<QuicConnectionPathStats> collectPathStats(int pathIdx) {
return collectPathStats(pathIdx, executor().newPromise());
Promise<QuicConnectionPathStats> promise = executor().newPromise();
collectPathStats(pathIdx, promise);
return promise;
}

/**
* Collects statistics about the path of the connection and notifies the {@link Promise} once done.
*
* @param promise the {@link Promise} that is notified once the stats were collected.
* @return the {@link Future} that is notified once the stats were collected.
* @param promise the {@link Promise} that is notified once the stats were collected.
*/
Future<QuicConnectionPathStats> collectPathStats(int pathIdx, Promise<QuicConnectionPathStats> promise);
void collectPathStats(int pathIdx, Promise<QuicConnectionPathStats> promise);

/**
* Creates a new {@link QuicChannelBootstrap} that can be used to create and connect new {@link QuicChannel}s to
Expand Down
11 changes: 5 additions & 6 deletions 11 codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicChannelBootstrap.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,17 @@ public QuicChannelBootstrap connectionAddress(QuicConnectionAddress connectionAd
* @return {@link Future} which is notified once the operation completes.
*/
public Future<QuicChannel> connect() {
return connect(parent.executor().newPromise());
Promise<QuicChannel> promise = parent.executor().newPromise();
connect(promise);
return promise;
}

/**
* Connects a {@link QuicChannel} to the remote peer and notifies the promise once done.
*
* @param promise the {@link Promise} which is notified once the operations completes.
* @return {@link Future} which is notified once the operation completes.

* @param promise the {@link Promise} which is notified once the operations completes.
*/
public Future<QuicChannel> connect(Promise<QuicChannel> promise) {
public void connect(Promise<QuicChannel> promise) {
if (handler == null && streamHandler == null) {
throw new IllegalStateException("handler and streamHandler not set");
}
Expand Down Expand Up @@ -239,6 +239,5 @@ public Future<QuicChannel> connect(Promise<QuicChannel> promise) {
});
}
});
return promise;
}
}
11 changes: 6 additions & 5 deletions 11 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 @@ -83,18 +83,19 @@ public interface QuicStreamChannel extends Channel {
* @return future that is notified once the operation completes.
*/
default Future<Void> updatePriority(QuicStreamPriority priority) {
return updatePriority(priority, newPromise());
Promise<Void> promise = newPromise();
updatePriority(priority, promise);
return promise;
}

/**
* Update the priority of the stream. A stream's priority determines the order in which stream data is sent
* on the wire (streams with lower priority are sent first).
*
* @param priority the priority.
* @param promise notified once operations completes.
* @return future that is notified once the operation completes.
* @param priority the priority.
* @param promise notified once operations completes.
*/
Future<Void> updatePriority(QuicStreamPriority priority, Promise<Void> promise);
void updatePriority(QuicStreamPriority priority, Promise<Void> promise);

@Override
QuicChannel parent();
Expand Down
11 changes: 6 additions & 5 deletions 11 codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicStreamChannelBootstrap.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,22 @@ public QuicStreamChannelBootstrap type(QuicStreamType type) {
* @return the {@link Future} that is notified once the operation completes.
*/
public Future<QuicStreamChannel> create() {
return create(parent.executor().newPromise());
Promise<QuicStreamChannel> promise = parent.executor().newPromise();
create(promise);
return promise;
}

/**
* Creates a new {@link QuicStreamChannel} and notifies the {@link Future}.
*
* @param promise the {@link Promise} that is notified once the operation completes.
* @return the {@link Future} that is notified once the operation completes.
* @param promise the {@link Promise} that is notified once the operation completes.
*/
public Future<QuicStreamChannel> create(Promise<QuicStreamChannel> promise) {
public void create(Promise<QuicStreamChannel> promise) {
if (handler == null) {
throw new IllegalStateException("streamHandler not set");
}

return parent.createStream(type, new QuicStreamChannelBootstrapHandler(handler,
parent.createStream(type, new QuicStreamChannelBootstrapHandler(handler,
Quic.toOptionsArray(options), Quic.toAttributesArray(attrs)), promise);
}

Expand Down
14 changes: 5 additions & 9 deletions 14 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 @@ -457,24 +457,22 @@ public QuicChannel read() {
}

@Override
public Future<QuicStreamChannel> createStream(QuicStreamType type, @Nullable ChannelHandler handler,
Promise<QuicStreamChannel> promise) {
public void createStream(QuicStreamType type, @Nullable ChannelHandler handler,
Promise<QuicStreamChannel> promise) {
if (executor().inEventLoop()) {
connectStream(type, handler, promise);
} else {
executor().execute(() -> connectStream(type, handler, promise));
}
return promise;
}

@Override
public Future<Void> close(boolean applicationClose, int error, ByteBuf reason, Promise<Void> promise) {
public void close(boolean applicationClose, int error, ByteBuf reason, Promise<Void> promise) {
if (executor().inEventLoop()) {
close0(applicationClose, error, reason, promise);
} else {
executor().execute(() -> close0(applicationClose, error, reason, promise));
}
return promise;
}

private void close0(boolean applicationClose, int error, ByteBuf reason, Promise<Void> promise) {
Expand Down Expand Up @@ -2032,13 +2030,12 @@ void cancel() {
}

@Override
public Future<QuicConnectionStats> collectStats(Promise<QuicConnectionStats> promise) {
public void collectStats(Promise<QuicConnectionStats> promise) {
if (executor().inEventLoop()) {
collectStats0(promise);
} else {
executor().execute(() -> collectStats0(promise));
}
return promise;
}

private void collectStats0(Promise<QuicConnectionStats> promise) {
Expand Down Expand Up @@ -2066,13 +2063,12 @@ private QuicConnectionStats collectStats0(QuicheQuicConnection connection, Promi
}

@Override
public Future<QuicConnectionPathStats> collectPathStats(int pathIdx, Promise<QuicConnectionPathStats> promise) {
public void collectPathStats(int pathIdx, Promise<QuicConnectionPathStats> promise) {
if (executor().inEventLoop()) {
collectPathStats0(pathIdx, promise);
} else {
executor().execute(() -> collectPathStats0(pathIdx, promise));
}
return promise;
}

private void collectPathStats0(int pathIdx, Promise<QuicConnectionPathStats> promise) {
Expand Down
3 changes: 1 addition & 2 deletions 3 codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@ public QuicStreamPriority priority() {
}

@Override
public Future<Void> updatePriority(QuicStreamPriority priority, Promise<Void> promise) {
public void updatePriority(QuicStreamPriority priority, Promise<Void> promise) {
if (executor().inEventLoop()) {
updatePriority0(priority, promise);
} else {
executor().execute(() -> updatePriority0(priority, promise));
}
return promise;
}

private void updatePriority0(QuicStreamPriority priority, Promise<Void> promise) {
Expand Down
9 changes: 4 additions & 5 deletions 9 codec-compression/src/main/java/io/netty/handler/codec/compression/BrotliEncoder.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.AttributeKey;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.Promise;
import io.netty.util.internal.ObjectUtil;

Expand Down Expand Up @@ -155,7 +154,7 @@ public void finish(ChannelHandlerContext ctx) throws IOException {
finishEncode(ctx, ctx.newPromise());
}

private Future<Void> finishEncode(ChannelHandlerContext ctx, Promise<Void> promise) {
private void finishEncode(ChannelHandlerContext ctx, Promise<Void> promise) {
Writer writer;

if (isSharable) {
Expand All @@ -168,13 +167,13 @@ private Future<Void> finishEncode(ChannelHandlerContext ctx, Promise<Void> promi
writer.close();
this.writer = null;
}
return promise;
}

@Override
public void close(final ChannelHandlerContext ctx, final Promise<Void> promise) {
Future<Void> f = finishEncode(ctx, ctx.newPromise());
EncoderUtil.closeAfterFinishEncode(ctx, f, promise);
Promise<Void> p = ctx.newPromise();
finishEncode(ctx, p);
EncoderUtil.closeAfterFinishEncode(ctx, p, promise);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions 24 codec-compression/src/main/java/io/netty/handler/codec/compression/Bzip2Encoder.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.Promise;
import io.netty.util.concurrent.PromiseNotifier;

import static io.netty.handler.codec.compression.Bzip2Constants.BASE_BLOCK_SIZE;
import static io.netty.handler.codec.compression.Bzip2Constants.END_OF_STREAM_MAGIC_1;
Expand Down Expand Up @@ -173,41 +172,42 @@ public boolean isClosed() {
* The returned {@link Future} will be notified once the operation completes.
*/
public Future<Void> close() {
return close(ctx().newPromise());
Promise<Void> promise = ctx().newPromise();
close(promise);
return promise;
}

/**
* Close this {@link Bzip2Encoder} and so finish the encoding.
* The given {@link Future} will be notified once the operation
* completes and will also be returned.
*/
public Future<Void> close(final Promise<Void> promise) {
public void close(final Promise<Void> promise) {
ChannelHandlerContext ctx = ctx();
EventExecutor executor = ctx.executor();
if (executor.inEventLoop()) {
return finishEncode(ctx, promise);
finishEncode(ctx, promise);
} else {
executor.execute(new Runnable() {
@Override
public void run() {
Future<Void> f = finishEncode(ctx(), promise);
PromiseNotifier.cascade(f, promise);
finishEncode(ctx(), promise);
}
});
return promise;
}
}

@Override
public void close(final ChannelHandlerContext ctx, final Promise<Void> promise) {
Future<Void> f = finishEncode(ctx, ctx.newPromise());
EncoderUtil.closeAfterFinishEncode(ctx, f, promise);
Promise<Void> p = ctx().newPromise();
finishEncode(ctx, p);
EncoderUtil.closeAfterFinishEncode(ctx, p, promise);
}

private Future<Void> finishEncode(final ChannelHandlerContext ctx, Promise<Void> promise) {
private void finishEncode(final ChannelHandlerContext ctx, Promise<Void> promise) {
if (finished) {
promise.setSuccess(null);
return promise;
return;
}
finished = true;

Expand All @@ -224,7 +224,7 @@ private Future<Void> finishEncode(final ChannelHandlerContext ctx, Promise<Void>
} finally {
blockCompressor = null;
}
return ctx.writeAndFlush(footer, promise);
ctx.writeAndFlush(footer, promise);
}

private ChannelHandlerContext ctx() {
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.