diff --git a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java index 3132feb7f8..524cf08aea 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -1052,15 +1052,5 @@ public class SslHandler public void setFailure(Throwable cause) { throw new IllegalStateException(); } - - @Override - public void setProgress(long amount, long current, long total) { - throw new IllegalStateException(); - } - - @Override - public boolean tryProgress(long amount, long current, long total) { - return false; - } } } diff --git a/transport/src/main/java/io/netty/channel/AbstractChannel.java b/transport/src/main/java/io/netty/channel/AbstractChannel.java index 3bbda12391..82793a30f0 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannel.java @@ -1018,16 +1018,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha throw new IllegalStateException(); } - @Override - public void setProgress(long amount, long current, long total) { - throw new IllegalStateException(); - } - - @Override - public boolean tryProgress(long amount, long current, long total) { - throw new IllegalStateException(); - } - @Override public boolean trySuccess() { throw new IllegalStateException(); diff --git a/transport/src/main/java/io/netty/channel/ChannelFutureProgressListener.java b/transport/src/main/java/io/netty/channel/ChannelFutureProgressListener.java deleted file mode 100644 index dcc93e0cb2..0000000000 --- a/transport/src/main/java/io/netty/channel/ChannelFutureProgressListener.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012 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: - * - * http://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; - - -/** - * Listens to the progress of a time-consuming I/O operation such as a large - * file transfer. If this listener is added to a {@link ChannelFuture} of an - * I/O operation that supports progress notification, the listener's - * {@link #operationProgressed(ChannelFuture, long, long, long)} method will be - * called back by an I/O thread. If the operation does not support progress - * notification, {@link #operationProgressed(ChannelFuture, long, long, long)} - * will not be invoked. Like a usual {@link ChannelFutureListener} that this - * interface extends, {@link #operationComplete(ChannelFuture)} will be called - * when the future is marked as complete. - * - *

Return the control to the caller quickly

- * - * {@link #operationProgressed(ChannelFuture, long, long, long)} and - * {@link #operationComplete(ChannelFuture)} is directly called by an I/O - * thread. Therefore, performing a time consuming task or a blocking operation - * in the handler method can cause an unexpected pause during I/O. If you need - * to perform a blocking operation on I/O completion, try to execute the - * operation in a different thread using a thread pool. - */ -public interface ChannelFutureProgressListener extends ChannelFutureListener { - - /** - * Invoked when the I/O operation associated with the {@link ChannelFuture} - * has been progressed. - * - * @param future the source {@link ChannelFuture} which called this - * callback - */ - void operationProgressed(ChannelFuture future, long amount, long current, long total) throws Exception; -} diff --git a/transport/src/main/java/io/netty/channel/ChannelPromise.java b/transport/src/main/java/io/netty/channel/ChannelPromise.java index b4bbe610cc..7f60d28d38 100644 --- a/transport/src/main/java/io/netty/channel/ChannelPromise.java +++ b/transport/src/main/java/io/netty/channel/ChannelPromise.java @@ -56,26 +56,6 @@ public interface ChannelPromise extends ChannelFuture { */ boolean tryFailure(Throwable cause); - /** - * Notifies the progress of the operation to the listeners that implements - * {@link ChannelFutureProgressListener}. Please note that this method will - * not do anything and return {@code false} if this future is complete - * already. - * - * If it is success or failed already it will throw an {@link IllegalStateException}. - */ - void setProgress(long amount, long current, long total); - - /** - * Notifies the progress of the operation to the listeners that implements - * {@link ChannelFutureProgressListener}. Please note that this method will - * not do anything and return {@code false} if this future is complete - * already. - * - * @return {@code true} if and only if notification was made. - */ - boolean tryProgress(long amount, long current, long total); - @Override ChannelPromise addListener(ChannelFutureListener listener); diff --git a/transport/src/main/java/io/netty/channel/CompleteChannelPromise.java b/transport/src/main/java/io/netty/channel/CompleteChannelPromise.java index 2fb63c6572..b06da8e615 100644 --- a/transport/src/main/java/io/netty/channel/CompleteChannelPromise.java +++ b/transport/src/main/java/io/netty/channel/CompleteChannelPromise.java @@ -22,16 +22,6 @@ abstract class CompleteChannelPromise extends CompleteChannelFuture implements C super(channel); } - @Override - public void setProgress(long amount, long current, long total) { - throw new IllegalStateException(); - } - - @Override - public boolean tryProgress(long amount, long current, long total) { - return false; - } - @Override public void setFailure(Throwable cause) { throw new IllegalStateException(); diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelPromise.java b/transport/src/main/java/io/netty/channel/DefaultChannelPromise.java index dc46d15308..a99b97c776 100644 --- a/transport/src/main/java/io/netty/channel/DefaultChannelPromise.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelPromise.java @@ -20,7 +20,6 @@ import io.netty.logging.InternalLogger; import io.netty.logging.InternalLoggerFactory; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; @@ -47,7 +46,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro private ChannelFutureListener firstListener; private List otherListeners; - private List progressListeners; private boolean done; private Throwable cause; private int waiters; @@ -106,13 +104,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro } otherListeners.add(listener); } - - if (listener instanceof ChannelFutureProgressListener) { - if (progressListeners == null) { - progressListeners = new ArrayList(1); - } - progressListeners.add((ChannelFutureProgressListener) listener); - } } } @@ -155,10 +146,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro } else if (otherListeners != null) { otherListeners.remove(listener); } - - if (listener instanceof ChannelFutureProgressListener) { - progressListeners.remove(listener); - } } } @@ -477,73 +464,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro } } - @Override - public void setProgress(long amount, long current, long total) { - ChannelFutureProgressListener[] plisteners; - synchronized (this) { - // Do not generate progress event after completion. - if (done) { - throw new IllegalStateException(); - } - - Collection progressListeners = - this.progressListeners; - if (progressListeners == null || progressListeners.isEmpty()) { - // Nothing to notify - no need to create an empty array. - return; - } - - plisteners = progressListeners.toArray( - new ChannelFutureProgressListener[progressListeners.size()]); - } - - for (ChannelFutureProgressListener pl: plisteners) { - notifyProgressListener(pl, amount, current, total); - } - } - - @Override - public boolean tryProgress(long amount, long current, long total) { - ChannelFutureProgressListener[] plisteners; - synchronized (this) { - // Do not generate progress event after completion. - if (done) { - return false; - } - - Collection progressListeners = - this.progressListeners; - if (progressListeners == null || progressListeners.isEmpty()) { - // Nothing to notify - no need to create an empty array. - return true; - } - - plisteners = progressListeners.toArray( - new ChannelFutureProgressListener[progressListeners.size()]); - } - - for (ChannelFutureProgressListener pl: plisteners) { - notifyProgressListener(pl, amount, current, total); - } - - return true; - } - - private void notifyProgressListener( - ChannelFutureProgressListener l, - long amount, long current, long total) { - - try { - l.operationProgressed(this, amount, current, total); - } catch (Throwable t) { - if (logger.isWarnEnabled()) { - logger.warn( - "An exception was thrown by " + - ChannelFutureProgressListener.class.getSimpleName() + '.', t); - } - } - } - @Override long flushCheckpoint() { return flushCheckpoint; diff --git a/transport/src/main/java/io/netty/channel/VoidChannelPromise.java b/transport/src/main/java/io/netty/channel/VoidChannelPromise.java index 2d76c962ce..9a7cdb189b 100644 --- a/transport/src/main/java/io/netty/channel/VoidChannelPromise.java +++ b/transport/src/main/java/io/netty/channel/VoidChannelPromise.java @@ -126,11 +126,6 @@ final class VoidChannelPromise implements ChannelFuture.Unsafe, ChannelPromise { fail(); return this; } - - @Override - public void setProgress(long amount, long current, long total) { - } - @Override public void setFailure(Throwable cause) { } @@ -139,11 +134,6 @@ final class VoidChannelPromise implements ChannelFuture.Unsafe, ChannelPromise { public void setSuccess() { } - @Override - public boolean tryProgress(long amount, long current, long total) { - return false; - } - @Override public boolean tryFailure(Throwable cause) { return false;