From 07baabaac57f876dd0c8908c7bd58a91c7774730 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 9 Jun 2021 08:32:38 +0200 Subject: [PATCH] Remove Progressive*Promise / Progressive*Future (#11374) Motivation: This special case implementation of Promise / Future requires the implementations responsible for completing the promise to have knowledge of this class to provide value. It also requires that the implementations are able to provide intermediate status while the work is being done. Even throughout the core of Netty it is not really supported most of the times and so just brings more complexity without real gain. Let's remove it completely which is better then only support it sometimes. Modifications: Remove Progressive* API Result: Code cleanup.... Fixes https://github.com/netty/netty/issues/8519 --- .../http/DelegatingChannelHandlerContext.java | 6 - .../http2/AbstractHttp2StreamChannel.java | 6 - .../codec/http2/Http2FrameInboundWriter.java | 6 - .../binary/BinaryMemcacheClientCodec.java | 5 - .../handler/codec/ByteToMessageDecoder.java | 6 - .../concurrent/AbstractEventExecutor.java | 5 - .../concurrent/DefaultFutureListeners.java | 19 --- .../concurrent/DefaultProgressivePromise.java | 110 -------------- .../netty/util/concurrent/DefaultPromise.java | 97 ------------ .../netty/util/concurrent/EventExecutor.java | 5 - .../GenericProgressiveFutureListener.java | 28 ---- .../concurrent/ImmediateEventExecutor.java | 16 -- .../util/concurrent/ProgressiveFuture.java | 38 ----- .../util/concurrent/ProgressivePromise.java | 56 ------- .../UnorderedThreadPoolEventExecutor.java | 5 - .../file/HttpStaticFileServerHandler.java | 19 +-- .../handler/stream/ChunkedWriteHandler.java | 16 +- .../EmbeddedChannelHandlerContext.java | 6 - .../AbstractSharedExecutorMicrobenchmark.java | 6 - .../io/netty/channel/AbstractChannel.java | 5 - .../netty/channel/ChannelOutboundBuffer.java | 6 - .../netty/channel/ChannelOutboundInvoker.java | 5 - .../channel/ChannelProgressiveFuture.java | 40 ----- .../ChannelProgressiveFutureListener.java | 28 ---- .../channel/ChannelProgressivePromise.java | 53 ------- .../channel/CombinedChannelDuplexHandler.java | 5 - .../channel/DefaultChannelHandlerContext.java | 5 - .../netty/channel/DefaultChannelPipeline.java | 5 - .../DefaultChannelProgressivePromise.java | 142 ------------------ 29 files changed, 7 insertions(+), 742 deletions(-) delete mode 100644 common/src/main/java/io/netty/util/concurrent/DefaultProgressivePromise.java delete mode 100644 common/src/main/java/io/netty/util/concurrent/GenericProgressiveFutureListener.java delete mode 100644 common/src/main/java/io/netty/util/concurrent/ProgressiveFuture.java delete mode 100644 common/src/main/java/io/netty/util/concurrent/ProgressivePromise.java delete mode 100644 transport/src/main/java/io/netty/channel/ChannelProgressiveFuture.java delete mode 100644 transport/src/main/java/io/netty/channel/ChannelProgressiveFutureListener.java delete mode 100644 transport/src/main/java/io/netty/channel/ChannelProgressivePromise.java delete mode 100644 transport/src/main/java/io/netty/channel/DefaultChannelProgressivePromise.java diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DelegatingChannelHandlerContext.java b/codec-http/src/main/java/io/netty/handler/codec/http/DelegatingChannelHandlerContext.java index 09f6005bdb..e6f8c26eca 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DelegatingChannelHandlerContext.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DelegatingChannelHandlerContext.java @@ -21,7 +21,6 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; import io.netty.util.Attribute; import io.netty.util.AttributeKey; @@ -246,11 +245,6 @@ abstract class DelegatingChannelHandlerContext implements ChannelHandlerContext return ctx.newPromise(); } - @Override - public ChannelProgressivePromise newProgressivePromise() { - return ctx.newProgressivePromise(); - } - @Override public ChannelFuture newSucceededFuture() { return ctx.newSucceededFuture(); diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java index 8d0ed01e1c..2de40c7a18 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java @@ -26,7 +26,6 @@ import io.netty.channel.ChannelId; import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelOutboundBuffer; import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; import io.netty.channel.DefaultChannelConfig; import io.netty.channel.DefaultChannelPipeline; @@ -489,11 +488,6 @@ abstract class AbstractHttp2StreamChannel extends DefaultAttributeMap implements return pipeline().newPromise(); } - @Override - public ChannelProgressivePromise newProgressivePromise() { - return pipeline().newProgressivePromise(); - } - @Override public ChannelFuture newSucceededFuture() { return pipeline().newSucceededFuture(); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java index f84ec6f5b9..c86a63a585 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java @@ -23,7 +23,6 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.Attribute; @@ -326,11 +325,6 @@ final class Http2FrameInboundWriter { return channel.newPromise(); } - @Override - public ChannelProgressivePromise newProgressivePromise() { - return channel.newProgressivePromise(); - } - @Override public ChannelFuture newSucceededFuture() { return channel.newSucceededFuture(); diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java index 848b40ee7d..21120cace8 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheClientCodec.java @@ -22,7 +22,6 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; import io.netty.channel.CombinedChannelDuplexHandler; import io.netty.handler.codec.PrematureChannelClosureException; @@ -280,10 +279,6 @@ public final class BinaryMemcacheClientCodec extends return ctx.newPromise(); } - public ChannelProgressivePromise newProgressivePromise() { - return ctx.newProgressivePromise(); - } - public ChannelFuture newSucceededFuture() { return ctx.newSucceededFuture(); } diff --git a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java index 6bee376b2b..fa0a7f8741 100644 --- a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java @@ -30,7 +30,6 @@ import io.netty.channel.ChannelHandler; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; import io.netty.channel.socket.ChannelInputShutdownEvent; import io.netty.util.Attribute; @@ -730,11 +729,6 @@ public abstract class ByteToMessageDecoder extends ChannelHandlerAdapter { return ctx.newPromise(); } - @Override - public ChannelProgressivePromise newProgressivePromise() { - return ctx.newProgressivePromise(); - } - @Override public ChannelFuture newSucceededFuture() { return ctx.newSucceededFuture(); diff --git a/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java index 8f66432207..83e2f652bc 100644 --- a/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java @@ -80,11 +80,6 @@ public abstract class AbstractEventExecutor extends AbstractExecutorService impl return new DefaultPromise<>(this); } - @Override - public ProgressivePromise newProgressivePromise() { - return new DefaultProgressivePromise<>(this); - } - @Override public Future newSucceededFuture(V result) { return new SucceededFuture<>(this, result); diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultFutureListeners.java b/common/src/main/java/io/netty/util/concurrent/DefaultFutureListeners.java index 8a2362daea..5e6b419b5d 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultFutureListeners.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultFutureListeners.java @@ -21,7 +21,6 @@ final class DefaultFutureListeners { private GenericFutureListener>[] listeners; private int size; - private int progressiveSize; // the number of progressive listeners @SuppressWarnings("unchecked") DefaultFutureListeners( @@ -30,12 +29,6 @@ final class DefaultFutureListeners { listeners[0] = first; listeners[1] = second; size = 2; - if (first instanceof GenericProgressiveFutureListener) { - progressiveSize ++; - } - if (second instanceof GenericProgressiveFutureListener) { - progressiveSize ++; - } } public void add(GenericFutureListener> l) { @@ -46,10 +39,6 @@ final class DefaultFutureListeners { } listeners[size] = l; this.size = size + 1; - - if (l instanceof GenericProgressiveFutureListener) { - progressiveSize ++; - } } public void remove(GenericFutureListener> l) { @@ -63,10 +52,6 @@ final class DefaultFutureListeners { } listeners[-- size] = null; this.size = size; - - if (l instanceof GenericProgressiveFutureListener) { - progressiveSize --; - } return; } } @@ -79,8 +64,4 @@ final class DefaultFutureListeners { public int size() { return size; } - - public int progressiveSize() { - return progressiveSize; - } } diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultProgressivePromise.java b/common/src/main/java/io/netty/util/concurrent/DefaultProgressivePromise.java deleted file mode 100644 index 2ee672e5b3..0000000000 --- a/common/src/main/java/io/netty/util/concurrent/DefaultProgressivePromise.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2013 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package io.netty.util.concurrent; - -import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero; - -public class DefaultProgressivePromise extends DefaultPromise implements ProgressivePromise { - - /** - * Creates a new instance. - * - * It is preferable to use {@link EventExecutor#newProgressivePromise()} to create a new progressive promise - * - * @param executor - * the {@link EventExecutor} which is used to notify the promise when it progresses or it is complete - */ - public DefaultProgressivePromise(EventExecutor executor) { - super(executor); - } - - @Override - public ProgressivePromise setProgress(long progress, long total) { - if (total < 0) { - // total unknown - total = -1; // normalize - checkPositiveOrZero(progress, "progress"); - } else if (progress < 0 || progress > total) { - throw new IllegalArgumentException( - "progress: " + progress + " (expected: 0 <= progress <= total (" + total + "))"); - } - - if (isDone()) { - throw new IllegalStateException("complete already"); - } - - notifyProgressiveListeners(progress, total); - return this; - } - - @Override - public boolean tryProgress(long progress, long total) { - if (total < 0) { - total = -1; - if (progress < 0 || isDone()) { - return false; - } - } else if (progress < 0 || progress > total || isDone()) { - return false; - } - - notifyProgressiveListeners(progress, total); - return true; - } - - @Override - public ProgressivePromise addListener(GenericFutureListener> listener) { - super.addListener(listener); - return this; - } - - @Override - public ProgressivePromise sync() throws InterruptedException { - super.sync(); - return this; - } - - @Override - public ProgressivePromise syncUninterruptibly() { - super.syncUninterruptibly(); - return this; - } - - @Override - public ProgressivePromise await() throws InterruptedException { - super.await(); - return this; - } - - @Override - public ProgressivePromise awaitUninterruptibly() { - super.awaitUninterruptibly(); - return this; - } - - @Override - public ProgressivePromise setSuccess(V result) { - super.setSuccess(result); - return this; - } - - @Override - public ProgressivePromise setFailure(Throwable cause) { - super.setFailure(cause); - return this; - } -} diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java index fcf2acf68f..8c218cd5df 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java @@ -580,103 +580,6 @@ public class DefaultPromise implements Promise { } } - /** - * Notify all progressive listeners. - *

- * No attempt is made to ensure notification order if multiple calls are made to this method before - * the original invocation completes. - *

- * This will do an iteration over all listeners to get all of type {@link GenericProgressiveFutureListener}s. - * @param progress the new progress. - * @param total the total progress. - */ - @SuppressWarnings("unchecked") - void notifyProgressiveListeners(final long progress, final long total) { - final Object listeners = progressiveListeners(); - if (listeners == null) { - return; - } - - final ProgressiveFuture self = (ProgressiveFuture) this; - - if (listeners instanceof GenericProgressiveFutureListener[]) { - final GenericProgressiveFutureListener[] array = - (GenericProgressiveFutureListener[]) listeners; - safeExecute(executor(), () -> notifyProgressiveListeners0(self, array, progress, total)); - } else { - final GenericProgressiveFutureListener> l = - (GenericProgressiveFutureListener>) listeners; - safeExecute(executor(), () -> notifyProgressiveListener0(self, l, progress, total)); - } - } - - /** - * Returns a {@link GenericProgressiveFutureListener}, an array of {@link GenericProgressiveFutureListener}, or - * {@code null}. - */ - private synchronized Object progressiveListeners() { - Object listeners = this.listeners; - if (listeners == null) { - // No listeners added - return null; - } - - if (listeners instanceof DefaultFutureListeners) { - // Copy DefaultFutureListeners into an array of listeners. - DefaultFutureListeners dfl = (DefaultFutureListeners) listeners; - int progressiveSize = dfl.progressiveSize(); - switch (progressiveSize) { - case 0: - return null; - case 1: - for (GenericFutureListener l: dfl.listeners()) { - if (l instanceof GenericProgressiveFutureListener) { - return l; - } - } - return null; - } - - GenericFutureListener[] array = dfl.listeners(); - GenericProgressiveFutureListener[] copy = new GenericProgressiveFutureListener[progressiveSize]; - for (int i = 0, j = 0; j < progressiveSize; i ++) { - GenericFutureListener l = array[i]; - if (l instanceof GenericProgressiveFutureListener) { - copy[j ++] = (GenericProgressiveFutureListener) l; - } - } - - return copy; - } else if (listeners instanceof GenericProgressiveFutureListener) { - return listeners; - } else { - // Only one listener was added and it's not a progressive listener. - return null; - } - } - - private static void notifyProgressiveListeners0( - ProgressiveFuture future, GenericProgressiveFutureListener[] listeners, long progress, long total) { - for (GenericProgressiveFutureListener l: listeners) { - if (l == null) { - break; - } - notifyProgressiveListener0(future, l, progress, total); - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private static void notifyProgressiveListener0( - ProgressiveFuture future, GenericProgressiveFutureListener l, long progress, long total) { - try { - l.operationProgressed(future, progress, total); - } catch (Throwable t) { - if (logger.isWarnEnabled()) { - logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationProgressed()", t); - } - } - } - private static boolean isCancelled0(Object result) { return result instanceof CauseHolder && ((CauseHolder) result).cause instanceof CancellationException; } diff --git a/common/src/main/java/io/netty/util/concurrent/EventExecutor.java b/common/src/main/java/io/netty/util/concurrent/EventExecutor.java index f6b1529a15..0d698afff2 100644 --- a/common/src/main/java/io/netty/util/concurrent/EventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/EventExecutor.java @@ -46,11 +46,6 @@ public interface EventExecutor extends EventExecutorGroup { */ Promise newPromise(); - /** - * Create a new {@link ProgressivePromise}. - */ - ProgressivePromise newProgressivePromise(); - /** * Create a new {@link Future} which is marked as succeeded already. So {@link Future#isSuccess()} * will return {@code true}. All {@link FutureListener} added to it will be notified directly. Also diff --git a/common/src/main/java/io/netty/util/concurrent/GenericProgressiveFutureListener.java b/common/src/main/java/io/netty/util/concurrent/GenericProgressiveFutureListener.java deleted file mode 100644 index 79ec49eddd..0000000000 --- a/common/src/main/java/io/netty/util/concurrent/GenericProgressiveFutureListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package io.netty.util.concurrent; - -public interface GenericProgressiveFutureListener> extends GenericFutureListener { - /** - * Invoked when the operation has progressed. - * - * @param progress the progress of the operation so far (cumulative) - * @param total the number that signifies the end of the operation when {@code progress} reaches at it. - * {@code -1} if the end of operation is unknown. - */ - void operationProgressed(F future, long progress, long total) throws Exception; -} diff --git a/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java index d4e6d9fd23..148e6af3dc 100644 --- a/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java @@ -129,11 +129,6 @@ public final class ImmediateEventExecutor extends AbstractEventExecutor { return new ImmediatePromise<>(this); } - @Override - public ProgressivePromise newProgressivePromise() { - return new ImmediateProgressivePromise<>(this); - } - @Override public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { @@ -165,15 +160,4 @@ public final class ImmediateEventExecutor extends AbstractEventExecutor { // No check } } - - static class ImmediateProgressivePromise extends DefaultProgressivePromise { - ImmediateProgressivePromise(EventExecutor executor) { - super(executor); - } - - @Override - protected void checkDeadLock() { - // No check - } - } } diff --git a/common/src/main/java/io/netty/util/concurrent/ProgressiveFuture.java b/common/src/main/java/io/netty/util/concurrent/ProgressiveFuture.java deleted file mode 100644 index c329993038..0000000000 --- a/common/src/main/java/io/netty/util/concurrent/ProgressiveFuture.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2013 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package io.netty.util.concurrent; - -/** - * A {@link Future} which is used to indicate the progress of an operation. - */ -public interface ProgressiveFuture extends Future { - - @Override - ProgressiveFuture addListener(GenericFutureListener> listener); - - @Override - ProgressiveFuture sync() throws InterruptedException; - - @Override - ProgressiveFuture syncUninterruptibly(); - - @Override - ProgressiveFuture await() throws InterruptedException; - - @Override - ProgressiveFuture awaitUninterruptibly(); -} diff --git a/common/src/main/java/io/netty/util/concurrent/ProgressivePromise.java b/common/src/main/java/io/netty/util/concurrent/ProgressivePromise.java deleted file mode 100644 index 992d998d71..0000000000 --- a/common/src/main/java/io/netty/util/concurrent/ProgressivePromise.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.util.concurrent; - -/** - * Special {@link ProgressiveFuture} which is writable. - */ -public interface ProgressivePromise extends Promise, ProgressiveFuture { - - /** - * Sets the current progress of the operation and notifies the listeners that implement - * {@link GenericProgressiveFutureListener}. - */ - ProgressivePromise setProgress(long progress, long total); - - /** - * Tries to set the current progress of the operation and notifies the listeners that implement - * {@link GenericProgressiveFutureListener}. If the operation is already complete or the progress is out of range, - * this method does nothing but returning {@code false}. - */ - boolean tryProgress(long progress, long total); - - @Override - ProgressivePromise setSuccess(V result); - - @Override - ProgressivePromise setFailure(Throwable cause); - - @Override - ProgressivePromise addListener(GenericFutureListener> listener); - - @Override - ProgressivePromise await() throws InterruptedException; - - @Override - ProgressivePromise awaitUninterruptibly(); - - @Override - ProgressivePromise sync() throws InterruptedException; - - @Override - ProgressivePromise syncUninterruptibly(); -} diff --git a/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java index 03a63b2a86..56d423fcc0 100644 --- a/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java @@ -97,11 +97,6 @@ public final class UnorderedThreadPoolEventExecutor extends ScheduledThreadPoolE return new DefaultPromise<>(this); } - @Override - public ProgressivePromise newProgressivePromise() { - return new DefaultProgressivePromise<>(this); - } - @Override public Future newSucceededFuture(V result) { return new SucceededFuture<>(this, result); diff --git a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java index e280540f84..3dd28878f4 100644 --- a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java +++ b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java @@ -20,8 +20,6 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelProgressiveFuture; -import io.netty.channel.ChannelProgressiveFutureListener; import io.netty.channel.DefaultFileRegion; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; @@ -197,29 +195,20 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler ProgressivePromise newProgressivePromise() { - return executor.newProgressivePromise(); - } - @Override public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { return executor.schedule(command, delay, unit); diff --git a/transport/src/main/java/io/netty/channel/AbstractChannel.java b/transport/src/main/java/io/netty/channel/AbstractChannel.java index 519c357124..827d8ace5a 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannel.java @@ -335,11 +335,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha return new DefaultChannelPromise(this, eventLoop); } - @Override - public ChannelProgressivePromise newProgressivePromise() { - return new DefaultChannelProgressivePromise(this, eventLoop); - } - @Override public ChannelFuture newSucceededFuture() { return succeedFuture; diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java index 83ced4a754..65ff74ab8a 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java @@ -19,7 +19,6 @@ import io.netty.buffer.ByteBufConvertible; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufHolder; import io.netty.buffer.Unpooled; -import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.ReferenceCountUtil; import io.netty.util.concurrent.FastThreadLocal; import io.netty.util.internal.InternalThreadLocalMap; @@ -243,9 +242,6 @@ public final class ChannelOutboundBuffer { ChannelPromise p = e.promise; long progress = e.progress + amount; e.progress = progress; - if (p instanceof ChannelProgressivePromise) { - ((ChannelProgressivePromise) p).tryProgress(progress, e.total); - } } /** @@ -378,7 +374,6 @@ public final class ChannelOutboundBuffer { *

* Note that the returned array is reused and thus should not escape * {@link AbstractChannel#doWrite(ChannelOutboundBuffer)}. - * Refer to {@link NioSocketChannel#doWrite(ChannelOutboundBuffer)} for an example. *

*/ public ByteBuffer[] nioBuffers() { @@ -392,7 +387,6 @@ public final class ChannelOutboundBuffer { *

* Note that the returned array is reused and thus should not escape * {@link AbstractChannel#doWrite(ChannelOutboundBuffer)}. - * Refer to {@link NioSocketChannel#doWrite(ChannelOutboundBuffer)} for an example. *

* @param maxCount The maximum amount of buffers that will be added to the return value. * @param maxBytes A hint toward the maximum number of bytes to include as part of the return value. Note that this diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundInvoker.java b/transport/src/main/java/io/netty/channel/ChannelOutboundInvoker.java index 030e725aee..b7547e15b1 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundInvoker.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundInvoker.java @@ -261,11 +261,6 @@ public interface ChannelOutboundInvoker { */ ChannelPromise newPromise(); - /** - * Return an new {@link ChannelProgressivePromise} - */ - ChannelProgressivePromise newProgressivePromise(); - /** * Create a new {@link ChannelFuture} which is marked as succeeded already. So {@link ChannelFuture#isSuccess()} * will return {@code true}. All {@link FutureListener} added to it will be notified directly. Also diff --git a/transport/src/main/java/io/netty/channel/ChannelProgressiveFuture.java b/transport/src/main/java/io/netty/channel/ChannelProgressiveFuture.java deleted file mode 100644 index ae5e922f0a..0000000000 --- a/transport/src/main/java/io/netty/channel/ChannelProgressiveFuture.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2013 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.channel; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; -import io.netty.util.concurrent.ProgressiveFuture; - -/** - * An special {@link ChannelFuture} which is used to indicate the {@link FileRegion} transfer progress - */ -public interface ChannelProgressiveFuture extends ChannelFuture, ProgressiveFuture { - @Override - ChannelProgressiveFuture addListener(GenericFutureListener> listener); - - @Override - ChannelProgressiveFuture sync() throws InterruptedException; - - @Override - ChannelProgressiveFuture syncUninterruptibly(); - - @Override - ChannelProgressiveFuture await() throws InterruptedException; - - @Override - ChannelProgressiveFuture awaitUninterruptibly(); -} diff --git a/transport/src/main/java/io/netty/channel/ChannelProgressiveFutureListener.java b/transport/src/main/java/io/netty/channel/ChannelProgressiveFutureListener.java deleted file mode 100644 index dee0268870..0000000000 --- a/transport/src/main/java/io/netty/channel/ChannelProgressiveFutureListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.channel; - -import io.netty.util.concurrent.GenericProgressiveFutureListener; - -import java.util.EventListener; - -/** - * An {@link EventListener} listener which will be called once the sending task associated with future is - * being transferred. - */ -public interface ChannelProgressiveFutureListener extends GenericProgressiveFutureListener { - // Just a type alias -} diff --git a/transport/src/main/java/io/netty/channel/ChannelProgressivePromise.java b/transport/src/main/java/io/netty/channel/ChannelProgressivePromise.java deleted file mode 100644 index 25440eef4e..0000000000 --- a/transport/src/main/java/io/netty/channel/ChannelProgressivePromise.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.channel; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; -import io.netty.util.concurrent.ProgressivePromise; - -/** - * Special {@link ChannelPromise} which will be notified once the associated bytes is transferring. - */ -public interface ChannelProgressivePromise extends ProgressivePromise, ChannelProgressiveFuture, ChannelPromise { - - @Override - ChannelProgressivePromise addListener(GenericFutureListener> listener); - - @Override - ChannelProgressivePromise sync() throws InterruptedException; - - @Override - ChannelProgressivePromise syncUninterruptibly(); - - @Override - ChannelProgressivePromise await() throws InterruptedException; - - @Override - ChannelProgressivePromise awaitUninterruptibly(); - - @Override - ChannelProgressivePromise setSuccess(Void result); - - @Override - ChannelProgressivePromise setSuccess(); - - @Override - ChannelProgressivePromise setFailure(Throwable cause); - - @Override - ChannelProgressivePromise setProgress(long progress, long total); -} diff --git a/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java b/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java index c720544cc9..5abd570825 100644 --- a/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java +++ b/transport/src/main/java/io/netty/channel/CombinedChannelDuplexHandler.java @@ -543,11 +543,6 @@ public class CombinedChannelDuplexHandler implements ChannelProgressivePromise, FlushCheckpoint { - - private final Channel channel; - private long checkpoint; - - /** - * Creates a new instance. - * - * @param channel - * the {@link Channel} associated with this future - */ - public DefaultChannelProgressivePromise(Channel channel) { - this(channel, channel.eventLoop()); - } - - /** - * Creates a new instance. - * - * @param channel - * the {@link Channel} associated with this future - */ - public DefaultChannelProgressivePromise(Channel channel, EventExecutor executor) { - super(executor); - this.channel = Objects.requireNonNull(channel, "channel"); - } - - @Override - public Channel channel() { - return channel; - } - - @Override - public ChannelProgressivePromise setSuccess() { - return setSuccess(null); - } - - @Override - public ChannelProgressivePromise setSuccess(Void result) { - super.setSuccess(result); - return this; - } - - @Override - public boolean trySuccess() { - return trySuccess(null); - } - - @Override - public ChannelProgressivePromise setFailure(Throwable cause) { - super.setFailure(cause); - return this; - } - - @Override - public ChannelProgressivePromise setProgress(long progress, long total) { - super.setProgress(progress, total); - return this; - } - - @Override - public ChannelProgressivePromise addListener(GenericFutureListener> listener) { - super.addListener(listener); - return this; - } - - @Override - public ChannelProgressivePromise sync() throws InterruptedException { - super.sync(); - return this; - } - - @Override - public ChannelProgressivePromise syncUninterruptibly() { - super.syncUninterruptibly(); - return this; - } - - @Override - public ChannelProgressivePromise await() throws InterruptedException { - super.await(); - return this; - } - - @Override - public ChannelProgressivePromise awaitUninterruptibly() { - super.awaitUninterruptibly(); - return this; - } - - @Override - public long flushCheckpoint() { - return checkpoint; - } - - @Override - public void flushCheckpoint(long checkpoint) { - this.checkpoint = checkpoint; - } - - @Override - public ChannelProgressivePromise promise() { - return this; - } - - @Override - protected void checkDeadLock() { - if (channel().isRegistered()) { - super.checkDeadLock(); - } - } -}