You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2015/09/07 15:42:44 UTC

[1/2] mina-sshd git commit: [SSHD-562] Use consistent semantics for 'await' vs. 'verify' in Future-like constructs

Repository: mina-sshd
Updated Branches:
  refs/heads/master bef33bc07 -> 9d39433bd


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/CloseableUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/CloseableUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/CloseableUtils.java
deleted file mode 100644
index 1d046d0..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/CloseableUtils.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.sshd.common.Closeable;
-import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.future.CloseFuture;
-import org.apache.sshd.common.future.DefaultCloseFuture;
-import org.apache.sshd.common.future.DefaultSshFuture;
-import org.apache.sshd.common.future.SshFuture;
-import org.apache.sshd.common.future.SshFutureListener;
-import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-
-/**
- * Utility class to help with {@link Closeable}s.
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public final class CloseableUtils {
-
-    /**
-     * Private Constructor
-     */
-    private CloseableUtils() {
-        throw new UnsupportedOperationException("No instance allowed");
-    }
-
-    // TODO once JDK 8+ becomes the minimum for this project, make it a static method in the Closeable interface
-    public static void close(Closeable closeable) throws IOException {
-        if (closeable == null) {
-            return;
-        }
-
-        if ((!closeable.isClosed()) && (!closeable.isClosing())) {
-            CloseFuture future = closeable.close(true);
-            future.await();  // TODO use verify + configurable timeout
-        }
-    }
-
-    public static CloseFuture closed() {
-        CloseFuture future = new DefaultCloseFuture(null);
-        future.setClosed();
-        return future;
-    }
-
-    public static final class Builder implements ObjectBuilder<Closeable> {
-
-        private final Object lock;
-        private final List<Closeable> closeables = new ArrayList<Closeable>();
-
-        private Builder(Object lock) {
-            this.lock = lock;
-        }
-
-        public Builder run(final Runnable r) {
-            return close(new SimpleCloseable(lock) {
-                @Override
-                protected void doClose(boolean immediately) {
-                    try {
-                        r.run();
-                    } finally {
-                        super.doClose(immediately);
-                    }
-                }
-            });
-        }
-
-        @SuppressWarnings("rawtypes")
-        public <T extends SshFuture> Builder when(SshFuture<T> future) {
-            if (future != null) {
-                when(Collections.singleton(future));
-            }
-            return this;
-        }
-
-        @SuppressWarnings("rawtypes")
-        public <T extends SshFuture> Builder when(@SuppressWarnings("unchecked") SshFuture<T>... futures) {
-            return when(Arrays.asList(futures));
-        }
-
-        @SuppressWarnings("rawtypes")
-        public <T extends SshFuture> Builder when(final Iterable<? extends SshFuture<T>> futures) {
-            return close(new FuturesCloseable<T>(lock, futures));
-        }
-
-        public Builder sequential(Closeable... closeables) {
-            for (Closeable closeable : closeables) {
-                close(closeable);
-            }
-            return this;
-        }
-
-        public Builder sequential(Iterable<Closeable> closeables) {
-            return close(new SequentialCloseable(lock, closeables));
-        }
-
-        public Builder parallel(Closeable... closeables) {
-            if (closeables.length == 1) {
-                close(closeables[0]);
-            } else if (closeables.length > 0) {
-                parallel(Arrays.asList(closeables));
-            }
-            return this;
-        }
-
-        @SuppressWarnings("synthetic-access")
-        public Builder parallel(Iterable<? extends Closeable> closeables) {
-            return close(new ParallelCloseable(lock, closeables));
-        }
-
-        public Builder close(Closeable c) {
-            if (c != null) {
-                closeables.add(c);
-            }
-            return this;
-        }
-
-        @Override
-        public Closeable build() {
-            if (closeables.isEmpty()) {
-                return new SimpleCloseable(lock);
-            } else if (closeables.size() == 1) {
-                return closeables.get(0);
-            } else {
-                return new SequentialCloseable(lock, closeables);
-            }
-        }
-
-    }
-
-    public abstract static class IoBaseCloseable extends AbstractLoggingBean implements Closeable {
-        protected IoBaseCloseable() {
-            this("");
-        }
-
-        protected IoBaseCloseable(String discriminator) {
-            super(discriminator);
-        }
-
-        // TODO once JDK 8+ becomes the minimum for this project, make it a default method instead of this class
-        @Override
-        public boolean isOpen() {
-            return !(isClosed() || isClosing());
-        }
-
-        // TODO once JDK 8+ becomes the minimum for this project, make it a default method instead of this class
-        @Override
-        public void close() throws IOException {
-            CloseableUtils.close(this);
-        }
-    }
-
-    private static class SimpleCloseable extends IoBaseCloseable {
-
-        protected final DefaultCloseFuture future;
-        protected final AtomicBoolean closing;
-
-        public SimpleCloseable(Object lock) {
-            future = new DefaultCloseFuture(lock);
-            closing = new AtomicBoolean();
-        }
-
-        @Override
-        public boolean isClosed() {
-            return future.isClosed();
-        }
-
-        @Override
-        public boolean isClosing() {
-            return closing.get();
-        }
-
-        @Override
-        public CloseFuture close(boolean immediately) {
-            if (closing.compareAndSet(false, true)) {
-                doClose(immediately);
-            }
-            return future;
-        }
-
-        protected void doClose(boolean immediately) {
-            future.setClosed();
-        }
-    }
-
-    private static final class ParallelCloseable extends SimpleCloseable {
-
-        private final Iterable<? extends Closeable> closeables;
-
-        private ParallelCloseable(Object lock, Iterable<? extends Closeable> closeables) {
-            super(lock);
-            this.closeables = closeables;
-        }
-
-        @Override
-        protected void doClose(final boolean immediately) {
-            final AtomicInteger count = new AtomicInteger(1);
-            SshFutureListener<CloseFuture> listener = new SshFutureListener<CloseFuture>() {
-                @Override
-                public void operationComplete(CloseFuture f) {
-                    if (count.decrementAndGet() == 0) {
-                        future.setClosed();
-                    }
-                }
-            };
-            for (Closeable c : closeables) {
-                if (c != null) {
-                    count.incrementAndGet();
-                    c.close(immediately).addListener(listener);
-                }
-            }
-            listener.operationComplete(null);
-        }
-    }
-
-    private static class SequentialCloseable extends SimpleCloseable {
-
-        private final Iterable<? extends Closeable> closeables;
-
-        public SequentialCloseable(Object lock, Iterable<? extends Closeable> closeables) {
-            super(lock);
-            this.closeables = closeables;
-        }
-
-        @Override
-        protected void doClose(final boolean immediately) {
-            final Iterator<? extends Closeable> iterator = closeables.iterator();
-            SshFutureListener<CloseFuture> listener = new SshFutureListener<CloseFuture>() {
-                @Override
-                public void operationComplete(CloseFuture previousFuture) {
-                    while (iterator.hasNext()) {
-                        Closeable c = iterator.next();
-                        if (c != null) {
-                            CloseFuture nextFuture = c.close(immediately);
-                            nextFuture.addListener(this);
-                            return;
-                        }
-                    }
-                    if (!iterator.hasNext()) {
-                        future.setClosed();
-                    }
-                }
-            };
-            listener.operationComplete(null);
-        }
-    }
-
-    private static class FuturesCloseable<T extends SshFuture> extends CloseableUtils.SimpleCloseable {
-
-        private final Iterable<? extends SshFuture<T>> futures;
-
-        public FuturesCloseable(Object lock, Iterable<? extends SshFuture<T>> futures) {
-            super(lock);
-            this.futures = futures;
-        }
-
-        @Override
-        protected void doClose(boolean immediately) {
-            if (immediately) {
-                for (SshFuture<?> f : futures) {
-                    if (f instanceof DefaultSshFuture) {
-                        ((DefaultSshFuture<?>) f).setValue(new SshException("Closed"));
-                    }
-                }
-                future.setClosed();
-            } else {
-                final AtomicInteger count = new AtomicInteger(1);
-                SshFutureListener<T> listener = new SshFutureListener<T>() {
-                    @Override
-                    public void operationComplete(T f) {
-                        if (count.decrementAndGet() == 0) {
-                            future.setClosed();
-                        }
-                    }
-                };
-                for (SshFuture<T> f : futures) {
-                    if (f != null) {
-                        count.incrementAndGet();
-                        f.addListener(listener);
-                    }
-                }
-                listener.operationComplete(null);
-            }
-        }
-    }
-
-    public abstract static class AbstractCloseable extends IoBaseCloseable {
-
-        protected enum State {
-            Opened, Graceful, Immediate, Closed
-        }
-
-        /**
-         * Lock object for this session state
-         */
-        protected final Object lock = new Object();
-        /**
-         * State of this object
-         */
-        protected final AtomicReference<State> state = new AtomicReference<>(State.Opened);
-        /**
-         * A future that will be set 'closed' when the object is actually closed
-         */
-        protected final CloseFuture closeFuture = new DefaultCloseFuture(lock);
-
-        protected AbstractCloseable() {
-            this("");
-        }
-
-        protected AbstractCloseable(String discriminator) {
-            super(discriminator);
-        }
-
-        @Override
-        public CloseFuture close(boolean immediately) {
-            if (immediately) {
-                if (state.compareAndSet(State.Opened, State.Immediate)
-                        || state.compareAndSet(State.Graceful, State.Immediate)) {
-                    log.debug("Closing {} immediately", this);
-                    preClose();
-                    doCloseImmediately();
-                    log.debug("{} closed", this);
-                } else {
-                    log.debug("{} is already {}", this, state.get() == State.Closed ? "closed" : "closing");
-                }
-            } else {
-                if (state.compareAndSet(State.Opened, State.Graceful)) {
-                    log.debug("Closing {} gracefully", this);
-                    preClose();
-                    SshFuture<CloseFuture> grace = doCloseGracefully();
-                    if (grace != null) {
-                        grace.addListener(new SshFutureListener<CloseFuture>() {
-                            @Override
-                            @SuppressWarnings("synthetic-access")
-                            public void operationComplete(CloseFuture future) {
-                                if (state.compareAndSet(State.Graceful, State.Immediate)) {
-                                    doCloseImmediately();
-                                    log.debug("{} closed", AbstractCloseable.this);
-                                }
-                            }
-                        });
-                    } else {
-                        if (state.compareAndSet(State.Graceful, State.Immediate)) {
-                            doCloseImmediately();
-                            log.debug("{} closed", this);
-                        }
-                    }
-                } else {
-                    log.debug("{} is already {}", this, state.get() == State.Closed ? "closed" : "closing");
-                }
-            }
-            return closeFuture;
-        }
-
-        @Override
-        public boolean isClosed() {
-            return state.get() == State.Closed;
-        }
-
-        @Override
-        public boolean isClosing() {
-            return state.get() != State.Opened;
-        }
-
-        /**
-         * preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.
-         * When preClose() is called, isClosing() == true
-         */
-        protected void preClose() {
-            // nothing
-        }
-
-        protected CloseFuture doCloseGracefully() {
-            return null;
-        }
-
-        /**
-         * <P>doCloseImmediately is called once and only once
-         * with state == Immediate</P>
-         *
-         * <P>Overriding methods should always call the base implementation.
-         * It may be called concurrently while preClose() or doCloseGracefully is executing</P>
-         */
-        protected void doCloseImmediately() {
-            closeFuture.setClosed();
-            state.set(State.Closed);
-        }
-
-        @SuppressWarnings("synthetic-access")
-        protected Builder builder() {
-            return new Builder(lock);
-        }
-
-    }
-
-    public abstract static class AbstractInnerCloseable extends AbstractCloseable {
-
-        protected AbstractInnerCloseable() {
-            this("");
-        }
-
-        protected AbstractInnerCloseable(String discriminator) {
-            super(discriminator);
-        }
-
-        protected abstract Closeable getInnerCloseable();
-
-        @Override
-        protected CloseFuture doCloseGracefully() {
-            return getInnerCloseable().close(false);
-        }
-
-        @Override
-        protected void doCloseImmediately() {
-            getInnerCloseable().close(true).addListener(new SshFutureListener<CloseFuture>() {
-                @Override
-                @SuppressWarnings("synthetic-access")
-                public void operationComplete(CloseFuture future) {
-                    AbstractInnerCloseable.super.doCloseImmediately();
-                }
-            });
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractCloseable.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractCloseable.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractCloseable.java
new file mode 100644
index 0000000..8aaa5b0
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractCloseable.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.DefaultCloseFuture;
+import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.future.SshFutureListener;
+
+/**
+ * Provides some default implementations
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractCloseable extends IoBaseCloseable {
+
+    public static enum State {
+        Opened, Graceful, Immediate, Closed
+    }
+
+    /**
+     * Lock object for this session state
+     */
+    protected final Object lock = new Object();
+    /**
+     * State of this object
+     */
+    protected final AtomicReference<AbstractCloseable.State> state = new AtomicReference<>(State.Opened);
+    /**
+     * A future that will be set 'closed' when the object is actually closed
+     */
+    protected final CloseFuture closeFuture = new DefaultCloseFuture(lock);
+
+    protected AbstractCloseable() {
+        this("");
+    }
+
+    protected AbstractCloseable(String discriminator) {
+        super(discriminator);
+    }
+
+    @Override
+    public CloseFuture close(boolean immediately) {
+        if (immediately) {
+            if (state.compareAndSet(State.Opened, State.Immediate)
+                    || state.compareAndSet(State.Graceful, State.Immediate)) {
+                log.debug("Closing {} immediately", this);
+                preClose();
+                doCloseImmediately();
+                log.debug("{} closed", this);
+            } else {
+                log.debug("{} is already {}", this, state.get() == State.Closed ? "closed" : "closing");
+            }
+        } else {
+            if (state.compareAndSet(State.Opened, State.Graceful)) {
+                log.debug("Closing {} gracefully", this);
+                preClose();
+                SshFuture<CloseFuture> grace = doCloseGracefully();
+                if (grace != null) {
+                    grace.addListener(new SshFutureListener<CloseFuture>() {
+                        @Override
+                        @SuppressWarnings("synthetic-access")
+                        public void operationComplete(CloseFuture future) {
+                            if (state.compareAndSet(State.Graceful, State.Immediate)) {
+                                doCloseImmediately();
+                                log.debug("{} closed", AbstractCloseable.this);
+                            }
+                        }
+                    });
+                } else {
+                    if (state.compareAndSet(State.Graceful, State.Immediate)) {
+                        doCloseImmediately();
+                        log.debug("{} closed", this);
+                    }
+                }
+            } else {
+                log.debug("{} is already {}", this, state.get() == State.Closed ? "closed" : "closing");
+            }
+        }
+        return closeFuture;
+    }
+
+    @Override
+    public boolean isClosed() {
+        return state.get() == State.Closed;
+    }
+
+    @Override
+    public boolean isClosing() {
+        return state.get() != State.Opened;
+    }
+
+    /**
+     * preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.
+     * When preClose() is called, isClosing() == true
+     */
+    protected void preClose() {
+        // nothing
+    }
+
+    protected CloseFuture doCloseGracefully() {
+        return null;
+    }
+
+    /**
+     * <P>doCloseImmediately is called once and only once
+     * with state == Immediate</P>
+     *
+     * <P>Overriding methods should always call the base implementation.
+     * It may be called concurrently while preClose() or doCloseGracefully is executing</P>
+     */
+    protected void doCloseImmediately() {
+        closeFuture.setClosed();
+        state.set(State.Closed);
+    }
+
+    protected Builder builder() {
+        return new Builder(lock);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractInnerCloseable.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractInnerCloseable.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractInnerCloseable.java
new file mode 100644
index 0000000..d3a7087
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/AbstractInnerCloseable.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.SshFutureListener;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractInnerCloseable extends AbstractCloseable {
+
+    protected AbstractInnerCloseable() {
+        this("");
+    }
+
+    protected AbstractInnerCloseable(String discriminator) {
+        super(discriminator);
+    }
+
+    protected abstract Closeable getInnerCloseable();
+
+    @Override
+    protected CloseFuture doCloseGracefully() {
+        return getInnerCloseable().close(false);
+    }
+
+    @Override
+    protected void doCloseImmediately() {
+        getInnerCloseable().close(true).addListener(new SshFutureListener<CloseFuture>() {
+            @Override
+            @SuppressWarnings("synthetic-access")
+            public void operationComplete(CloseFuture future) {
+                AbstractInnerCloseable.super.doCloseImmediately();
+            }
+        });
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/Builder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/Builder.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/Builder.java
new file mode 100644
index 0000000..375159a
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/Builder.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.util.ObjectBuilder;
+import org.apache.sshd.common.util.ValidateUtils;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public final class Builder implements ObjectBuilder<Closeable> {
+
+    private final Object lock;
+    private final List<Closeable> closeables = new ArrayList<Closeable>();
+
+    public Builder(Object lock) {
+        this.lock = ValidateUtils.checkNotNull(lock, "No lock");
+    }
+
+    public Builder run(final Runnable r) {
+        return close(new SimpleCloseable(lock) {
+            @Override
+            protected void doClose(boolean immediately) {
+                try {
+                    r.run();
+                } finally {
+                    super.doClose(immediately);
+                }
+            }
+        });
+    }
+
+    @SuppressWarnings("rawtypes")
+    public <T extends SshFuture> Builder when(SshFuture<T> future) {
+        if (future != null) {
+            when(Collections.singleton(future));
+        }
+        return this;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public <T extends SshFuture> Builder when(@SuppressWarnings("unchecked") SshFuture<T>... futures) {
+        return when(Arrays.asList(futures));
+    }
+
+    @SuppressWarnings("rawtypes")
+    public <T extends SshFuture> Builder when(final Iterable<? extends SshFuture<T>> futures) {
+        return close(new FuturesCloseable<T>(lock, futures));
+    }
+
+    public Builder sequential(Closeable... closeables) {
+        for (Closeable closeable : closeables) {
+            close(closeable);
+        }
+        return this;
+    }
+
+    public Builder sequential(Iterable<Closeable> closeables) {
+        return close(new SequentialCloseable(lock, closeables));
+    }
+
+    public Builder parallel(Closeable... closeables) {
+        if (closeables.length == 1) {
+            close(closeables[0]);
+        } else if (closeables.length > 0) {
+            parallel(Arrays.asList(closeables));
+        }
+        return this;
+    }
+
+    public Builder parallel(Iterable<? extends Closeable> closeables) {
+        return close(new ParallelCloseable(lock, closeables));
+    }
+
+    public Builder close(Closeable c) {
+        if (c != null) {
+            closeables.add(c);
+        }
+        return this;
+    }
+
+    @Override
+    public Closeable build() {
+        if (closeables.isEmpty()) {
+            return new SimpleCloseable(lock);
+        } else if (closeables.size() == 1) {
+            return closeables.get(0);
+        } else {
+            return new SequentialCloseable(lock, closeables);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/CloseableUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/CloseableUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/CloseableUtils.java
new file mode 100644
index 0000000..172ce99
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/CloseableUtils.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.io.IOException;
+
+import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.DefaultCloseFuture;
+
+/**
+ * Utility class to help with {@link Closeable}s.
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public final class CloseableUtils {
+
+    /**
+     * Private Constructor
+     */
+    private CloseableUtils() {
+        throw new UnsupportedOperationException("No instance allowed");
+    }
+
+    // TODO once JDK 8+ becomes the minimum for this project, make it a static method in the Closeable interface
+    public static void close(Closeable closeable) throws IOException {
+        if (closeable == null) {
+            return;
+        }
+
+        if ((!closeable.isClosed()) && (!closeable.isClosing())) {
+            CloseFuture future = closeable.close(true);
+            future.await();  // TODO use verify + configurable timeout
+        }
+    }
+
+    public static CloseFuture closed() {
+        CloseFuture future = new DefaultCloseFuture(null);
+        future.setClosed();
+        return future;
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java
new file mode 100644
index 0000000..62c427d
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/FuturesCloseable.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.sshd.common.SshException;
+import org.apache.sshd.common.future.DefaultSshFuture;
+import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.future.SshFutureListener;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class FuturesCloseable<T extends SshFuture> extends SimpleCloseable {
+
+    private final Iterable<? extends SshFuture<T>> futures;
+
+    public FuturesCloseable(Object lock, Iterable<? extends SshFuture<T>> futures) {
+        super(lock);
+        this.futures = (futures == null) ? Collections.<SshFuture<T>>emptyList() : futures;
+    }
+
+    @Override
+    protected void doClose(final boolean immediately) {
+        if (immediately) {
+            for (SshFuture<?> f : futures) {
+                if (f instanceof DefaultSshFuture) {
+                    ((DefaultSshFuture<?>) f).setValue(new SshException("Closed"));
+                }
+            }
+            future.setClosed();
+        } else {
+            final AtomicInteger count = new AtomicInteger(1);
+            SshFutureListener<T> listener = new SshFutureListener<T>() {
+                @SuppressWarnings("synthetic-access")
+                @Override
+                public void operationComplete(T f) {
+                    int pendingCount = count.decrementAndGet();
+                    if (log.isTraceEnabled()) {
+                        log.trace("doClose(" + immediately + ") complete pending: " + pendingCount);
+                    }
+                    if (pendingCount == 0) {
+                        future.setClosed();
+                    }
+                }
+            };
+            for (SshFuture<T> f : futures) {
+                if (f != null) {
+                    int pendingCount = count.incrementAndGet();
+                    if (log.isTraceEnabled()) {
+                        log.trace("doClose(" + immediately + ") future pending: " + pendingCount);
+                    }
+                    f.addListener(listener);
+                }
+            }
+            listener.operationComplete(null);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/IoBaseCloseable.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/IoBaseCloseable.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/IoBaseCloseable.java
new file mode 100644
index 0000000..d4af9d1
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/IoBaseCloseable.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.io.IOException;
+
+import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class IoBaseCloseable extends AbstractLoggingBean implements Closeable {
+    protected IoBaseCloseable() {
+        this("");
+    }
+
+    protected IoBaseCloseable(String discriminator) {
+        super(discriminator);
+    }
+
+    // TODO once JDK 8+ becomes the minimum for this project, make it a default method instead of this class
+    @Override
+    public boolean isOpen() {
+        return !(isClosed() || isClosing());
+    }
+
+    // TODO once JDK 8+ becomes the minimum for this project, make it a default method instead of this class
+    @Override
+    public void close() throws IOException {
+        CloseableUtils.close(this);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java
new file mode 100644
index 0000000..e611206
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/ParallelCloseable.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.SshFutureListener;
+
+/**
+ * Waits for a group of {@link Closeable}s to complete in any order, then
+ * signals the completion by setting the &quot;parent&quot; future as closed
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class ParallelCloseable extends SimpleCloseable {
+
+    private final Iterable<? extends Closeable> closeables;
+
+    public ParallelCloseable(Object lock, Iterable<? extends Closeable> closeables) {
+        super(lock);
+        this.closeables = (closeables == null) ? Collections.<Closeable>emptyList() : closeables;
+    }
+
+    @Override
+    protected void doClose(final boolean immediately) {
+        final AtomicInteger count = new AtomicInteger(1);
+        SshFutureListener<CloseFuture> listener = new SshFutureListener<CloseFuture>() {
+            @SuppressWarnings("synthetic-access")
+            @Override
+            public void operationComplete(CloseFuture f) {
+                int pendingCount = count.decrementAndGet();
+                if (log.isTraceEnabled()) {
+                    log.trace("doClose(" + immediately + ") completed pending: " + pendingCount);
+                }
+                if (pendingCount == 0) {
+                    future.setClosed();
+                }
+            }
+        };
+        for (Closeable c : closeables) {
+            if (c != null) {
+                int pendingCount = count.incrementAndGet();
+                if (log.isTraceEnabled()) {
+                    log.trace("doClose(" + immediately + ") pending closeables: " + pendingCount);
+                }
+                c.close(immediately).addListener(listener);
+            }
+        }
+        listener.operationComplete(null);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SequentialCloseable.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SequentialCloseable.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SequentialCloseable.java
new file mode 100644
index 0000000..3a91831
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SequentialCloseable.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.SshFutureListener;
+
+/**
+ * Waits for a group of {@link Closeable}s to complete in the given order, then
+ * signals the completion by setting the &quot;parent&quot; future as closed
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class SequentialCloseable extends SimpleCloseable {
+
+    private final Iterable<? extends Closeable> closeables;
+
+    public SequentialCloseable(Object lock, Iterable<? extends Closeable> closeables) {
+        super(lock);
+        this.closeables = (closeables == null) ? Collections.<Closeable>emptyList() : closeables;
+    }
+
+    @Override
+    protected void doClose(final boolean immediately) {
+        final Iterator<? extends Closeable> iterator = closeables.iterator();
+        SshFutureListener<CloseFuture> listener = new SshFutureListener<CloseFuture>() {
+            @SuppressWarnings("synthetic-access")
+            @Override
+            public void operationComplete(CloseFuture previousFuture) {
+                while (iterator.hasNext()) {
+                    Closeable c = iterator.next();
+                    if (c != null) {
+                        if (log.isTraceEnabled()) {
+                            log.trace("doClose(" + immediately + ") closing " + c);
+                        }
+                        CloseFuture nextFuture = c.close(immediately);
+                        nextFuture.addListener(this);
+                        return;
+                    }
+                }
+                if (!iterator.hasNext()) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("doClose(" + immediately + ") signal close complete");
+                    }
+                    future.setClosed();
+                }
+            }
+        };
+        listener.operationComplete(null);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SimpleCloseable.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SimpleCloseable.java b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SimpleCloseable.java
new file mode 100644
index 0000000..7bda0c6
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/closeable/SimpleCloseable.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.DefaultCloseFuture;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class SimpleCloseable extends IoBaseCloseable {
+
+    protected final DefaultCloseFuture future;
+    protected final AtomicBoolean closing;
+
+    public SimpleCloseable(Object lock) {
+        future = new DefaultCloseFuture(lock);
+        closing = new AtomicBoolean();
+    }
+
+    @Override
+    public boolean isClosed() {
+        return future.isClosed();
+    }
+
+    @Override
+    public boolean isClosing() {
+        return closing.get();
+    }
+
+    @Override
+    public CloseFuture close(boolean immediately) {
+        if (closing.compareAndSet(false, true)) {
+            doClose(immediately);
+        }
+        return future;
+    }
+
+    protected void doClose(boolean immediately) {
+        future.setClosed();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index 7041cbc..8d722e7 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -48,11 +48,11 @@ import org.apache.sshd.common.file.FileSystemFactory;
 import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.future.DefaultCloseFuture;
 import org.apache.sshd.common.future.SshFutureListener;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.closeable.IoBaseCloseable;
 import org.apache.sshd.common.util.io.IoUtils;
 import org.apache.sshd.common.util.io.LoggingFilterOutputStream;
 import org.apache.sshd.server.AsyncCommand;
@@ -216,7 +216,7 @@ public class ChannelSession extends AbstractServerChannel {
                 .build();
     }
 
-    public class CommandCloseable extends CloseableUtils.IoBaseCloseable {
+    public class CommandCloseable extends IoBaseCloseable {
         @Override
         public boolean isClosed() {
             return commandExitFuture.isClosed();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
index 1881f39..86627ee 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
@@ -31,17 +31,17 @@ import org.apache.sshd.common.Service;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 import org.apache.sshd.server.ServerFactoryManager;
 import org.apache.sshd.server.auth.UserAuth;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class ServerUserAuthService extends CloseableUtils.AbstractCloseable implements Service {
+public class ServerUserAuthService extends AbstractCloseable implements Service {
 
     public static final int DEFAULT_MAX_AUTH_REQUESTS = 20;
     private final ServerSession session;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java b/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
index efb14d9..855d368 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
@@ -39,16 +39,16 @@ import org.apache.sshd.common.io.IoServiceFactory;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.Readable;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class X11ForwardSupport extends CloseableUtils.AbstractInnerCloseable implements IoHandler {
+public class X11ForwardSupport extends AbstractInnerCloseable implements IoHandler {
 
     /**
      * Configuration value on the {@link FactoryManager} to control the

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
index 194a77e..1c7b57a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
@@ -86,8 +86,7 @@ public class AuthenticationTest extends BaseTestSupport {
             client.start();
             try (ClientSession s = client.connect("user", TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
                 s.addPasswordIdentity("bad password");
-                assertTrue(s.auth().await().isFailure());
-
+                assertAuthenticationResult(getCurrentTestName(), s.auth(), false);
             }
         }
     }
@@ -105,8 +104,9 @@ public class AuthenticationTest extends BaseTestSupport {
             try (ClientSession s = client.connect(null, TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
                 s.waitFor(ClientSession.CLOSED | ClientSession.WAIT_AUTH, 0);
 
-                assertFalse("Unexpected user1 password auth success", authPassword(s, "user1", "the-password").await().isSuccess());
-                assertFalse("Unexpected user2 password auth success", authPassword(s, "user2", "the-password").await().isSuccess());
+                for (String username : new String[]{"user1", "user2"}) {
+                    assertAuthenticationResult(username, authPassword(s, username, "the-password"), false);
+                }
 
                 // Note that WAIT_AUTH flag should be false, but since the internal
                 // authentication future is not updated, it's still returned
@@ -128,9 +128,7 @@ public class AuthenticationTest extends BaseTestSupport {
 
             try (ClientSession s = client.connect(null, TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
                 s.waitFor(ClientSession.CLOSED | ClientSession.WAIT_AUTH, 0);
-
-                assertFalse("Unexpected password auth sucess", authPassword(s, getCurrentTestName(), getCurrentTestName()).await().isSuccess());
-
+                assertAuthenticationResult(getCurrentTestName(), authPassword(s, getCurrentTestName(), getCurrentTestName()), false);
                 s.close(true);
             } finally {
                 client.stop();
@@ -151,8 +149,8 @@ public class AuthenticationTest extends BaseTestSupport {
                 s.waitFor(ClientSession.CLOSED | ClientSession.WAIT_AUTH, 0);
 
                 KeyPair pair = createTestHostKeyProvider().loadKey(KeyPairProvider.SSH_RSA);
-                assertFalse("Unexpected pubkey auth success", authPublicKey(s, getCurrentTestName(), pair).await().isSuccess());
-                assertTrue("Failed password auth", authPassword(s, getCurrentTestName(), getCurrentTestName()).await().isSuccess());
+                assertAuthenticationResult("pubkey", authPublicKey(s, getCurrentTestName(), pair), false);
+                assertAuthenticationResult("password", authPassword(s, getCurrentTestName(), getCurrentTestName()), true);
                 s.close(true);
             } finally {
                 client.stop();
@@ -173,8 +171,8 @@ public class AuthenticationTest extends BaseTestSupport {
                 s.waitFor(ClientSession.CLOSED | ClientSession.WAIT_AUTH, 0);
 
                 KeyPair pair = createTestHostKeyProvider().loadKey(KeyPairProvider.SSH_RSA);
-                assertFalse("Unexpected pubkey auth success", authPublicKey(s, getCurrentTestName(), pair).await().isSuccess());
-                assertTrue("Failed password auth", authInteractive(s, getCurrentTestName(), getCurrentTestName()).await().isSuccess());
+                assertAuthenticationResult("pubkey", authPublicKey(s, getCurrentTestName(), pair), false);
+                assertAuthenticationResult("interactive", authInteractive(s, getCurrentTestName(), getCurrentTestName()), true);
 
                 s.close(true);
             } finally {
@@ -183,6 +181,11 @@ public class AuthenticationTest extends BaseTestSupport {
         }
     }
 
+    private static void assertAuthenticationResult(String message, AuthFuture future, boolean expected) throws IOException {
+        assertTrue(message + ": failed to get result on time", future.await(5L, TimeUnit.SECONDS));
+        assertEquals(message + ": mismatched authentication result", expected, future.isSuccess());
+    }
+
     private AuthFuture authPassword(ClientSession s, String user, String pswd) throws IOException {
         s.setUsername(user);
         return s.getService(ClientUserAuthServiceOld.class)

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java b/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
index 184bd50..e87d425 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.sshd.client.SshClient;
+import org.apache.sshd.client.future.AuthFuture;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.FactoryManagerUtils;
 import org.apache.sshd.common.config.keys.KeyUtils;
@@ -142,7 +143,10 @@ public class SinglePublicKeyAuthTest extends BaseTestSupport {
             try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
                 session.addPublicKeyIdentity(pairRsaBad);
                 session.addPublicKeyIdentity(pairRsa);
-                assertTrue("Failed to authenticate", session.auth().await().isSuccess());
+
+                AuthFuture auth = session.auth();
+                assertTrue("Failed to authenticate on time", auth.await(5L, TimeUnit.SECONDS));
+                assertTrue("Authentication failed", auth.isSuccess());
             } finally {
                 client.stop();
             }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
index f12ec3e..e82a578 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
@@ -935,6 +935,10 @@ public class SftpTest extends AbstractSftpClientTestSupport {
         Path sourcePath = assertHierarchyTargetFolderExists(lclSftp).resolve("src.txt");
         String remSrcPath = "/" + Utils.resolveRelativeRemotePath(parentPath, sourcePath);
         Path linkPath = lclSftp.resolve("link-" + sourcePath.getFileName());
+        if (Files.exists(linkPath, IoUtils.EMPTY_LINK_OPTIONS)) {
+            Files.delete(linkPath);
+        }
+
         String remLinkPath = "/" + Utils.resolveRelativeRemotePath(parentPath, linkPath);
 
         String data = getCurrentTestName();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
deleted file mode 100644
index 11eeb3d..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.sshd.common.Closeable;
-import org.apache.sshd.common.future.CloseFuture;
-import org.apache.sshd.common.future.DefaultCloseFuture;
-import org.apache.sshd.common.util.threads.ThreadUtils;
-import org.apache.sshd.util.test.BaseTestSupport;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class CloseableUtilsTest extends BaseTestSupport {
-    public CloseableUtilsTest() {
-        super();
-    }
-
-    @Test
-    public void testCloseImmediateNotCalledIfAlreadyClosed() throws IOException {
-        Closeable closeable = new CloseableUtils.IoBaseCloseable() {
-            @Override
-            public CloseFuture close(boolean immediately) {
-                fail("Unexpected call to close(" + immediately + ")");
-                return null;
-            }
-
-            @Override
-            public boolean isClosed() {
-                return true;
-            }
-
-            @Override
-            public boolean isClosing() {
-                return false;
-            }
-        };
-        closeable.close();
-    }
-
-    @Test
-    public void testCloseImmediateNotCalledIfIsClosing() throws IOException {
-        Closeable closeable = new CloseableUtils.IoBaseCloseable() {
-            @Override
-            public CloseFuture close(boolean immediately) {
-                fail("Unexpected call to close(" + immediately + ")");
-                return null;
-            }
-
-            @Override
-            public boolean isClosed() {
-                return false;
-            }
-
-            @Override
-            public boolean isClosing() {
-                return true;
-            }
-        };
-        closeable.close();
-    }
-
-    @Test
-    public void testCloseImmediateCalledAndWait() throws Exception {
-        final DefaultCloseFuture future = new DefaultCloseFuture(this);
-        final AtomicInteger callsCount = new AtomicInteger(0);
-        final Closeable closeable = new CloseableUtils.IoBaseCloseable() {
-            @Override
-            public CloseFuture close(boolean immediately) {
-                assertTrue("Closure is not immediate", immediately);
-                assertEquals("Multiple close immediate calls", 1, callsCount.incrementAndGet());
-                return future;
-            }
-
-            @Override
-            public boolean isClosed() {
-                return false;
-            }
-
-            @Override
-            public boolean isClosing() {
-                return false;
-            }
-        };
-        ExecutorService service = ThreadUtils.newSingleThreadExecutor(getCurrentTestName());
-        try {
-            Future<?> task = service.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        closeable.close();
-                    } catch (IOException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            });
-            future.setClosed();  // signal close complete
-            task.get(5L, TimeUnit.SECONDS);  // make sure #await call terminated
-            assertEquals("Close immediate not called", 1, callsCount.get());
-        } finally {
-            service.shutdownNow();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/test/java/org/apache/sshd/common/util/closeable/CloseableUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/closeable/CloseableUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/closeable/CloseableUtilsTest.java
new file mode 100644
index 0000000..8d8d807
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/closeable/CloseableUtilsTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.util.closeable;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.sshd.common.Closeable;
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.DefaultCloseFuture;
+import org.apache.sshd.common.util.threads.ThreadUtils;
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class CloseableUtilsTest extends BaseTestSupport {
+    public CloseableUtilsTest() {
+        super();
+    }
+
+    @Test
+    public void testCloseImmediateNotCalledIfAlreadyClosed() throws IOException {
+        Closeable closeable = new IoBaseCloseable() {
+            @Override
+            public CloseFuture close(boolean immediately) {
+                fail("Unexpected call to close(" + immediately + ")");
+                return null;
+            }
+
+            @Override
+            public boolean isClosed() {
+                return true;
+            }
+
+            @Override
+            public boolean isClosing() {
+                return false;
+            }
+        };
+        closeable.close();
+    }
+
+    @Test
+    public void testCloseImmediateNotCalledIfIsClosing() throws IOException {
+        Closeable closeable = new IoBaseCloseable() {
+            @Override
+            public CloseFuture close(boolean immediately) {
+                fail("Unexpected call to close(" + immediately + ")");
+                return null;
+            }
+
+            @Override
+            public boolean isClosed() {
+                return false;
+            }
+
+            @Override
+            public boolean isClosing() {
+                return true;
+            }
+        };
+        closeable.close();
+    }
+
+    @Test
+    public void testCloseImmediateCalledAndWait() throws Exception {
+        final DefaultCloseFuture future = new DefaultCloseFuture(this);
+        final AtomicInteger callsCount = new AtomicInteger(0);
+        final Closeable closeable = new IoBaseCloseable() {
+            @Override
+            public CloseFuture close(boolean immediately) {
+                assertTrue("Closure is not immediate", immediately);
+                assertEquals("Multiple close immediate calls", 1, callsCount.incrementAndGet());
+                return future;
+            }
+
+            @Override
+            public boolean isClosed() {
+                return false;
+            }
+
+            @Override
+            public boolean isClosing() {
+                return false;
+            }
+        };
+        ExecutorService service = ThreadUtils.newSingleThreadExecutor(getCurrentTestName());
+        try {
+            Future<?> task = service.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        closeable.close();
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            });
+            future.setClosed();  // signal close complete
+            task.get(5L, TimeUnit.SECONDS);  // make sure #await call terminated
+            assertEquals("Close immediate not called", 1, callsCount.get());
+        } finally {
+            service.shutdownNow();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
index a969502..1938304 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
@@ -29,8 +29,8 @@ import org.apache.sshd.common.ServiceFactory;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 import org.apache.sshd.deprecated.UserAuth.Result;
 
 /**
@@ -38,7 +38,7 @@ import org.apache.sshd.deprecated.UserAuth.Result;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class ClientUserAuthServiceOld extends CloseableUtils.AbstractCloseable implements Service {
+public class ClientUserAuthServiceOld extends AbstractCloseable implements Service {
 
     public static class Factory implements ServiceFactory {
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
index 43a97db..21992b0 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
@@ -248,8 +248,7 @@ public class Utils {
             // same logic as deleteRecursive(File) which does not check if deletion succeeded
             System.err.append("Failed (").append(e.getClass().getSimpleName()).append(")")
                     .append(" to delete ").append(path.toString())
-                    .append(": ").println(e.getMessage())
-            ;
+                    .append(": ").println(e.getMessage());
         }
 
         return path;


[2/2] mina-sshd git commit: [SSHD-562] Use consistent semantics for 'await' vs. 'verify' in Future-like constructs

Posted by lg...@apache.org.
[SSHD-562] Use consistent semantics for 'await' vs. 'verify' in Future-like constructs


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/9d39433b
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/9d39433b
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/9d39433b

Branch: refs/heads/master
Commit: 9d39433bd827dd06500df8bbd341b22dd14ef7b3
Parents: bef33bc
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Mon Sep 7 16:42:33 2015 +0300
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Mon Sep 7 16:42:33 2015 +0300

----------------------------------------------------------------------
 .../sshd/agent/common/AgentForwardSupport.java  |   4 +-
 .../java/org/apache/sshd/client/SshClient.java  |   2 +-
 .../apache/sshd/client/future/AuthFuture.java   |  38 +-
 .../sshd/client/future/ConnectFuture.java       |  42 +-
 .../sshd/client/future/DefaultAuthFuture.java   |  19 +-
 .../client/future/DefaultConnectFuture.java     |  10 +-
 .../sshd/client/future/DefaultOpenFuture.java   |  19 +-
 .../apache/sshd/client/future/OpenFuture.java   |  33 +-
 .../client/session/ClientUserAuthService.java   |   4 +-
 .../sshd/common/AbstractFactoryManager.java     |   4 +-
 .../sshd/common/channel/AbstractChannel.java    |   7 +-
 .../common/channel/BufferedIoOutputStream.java  |   4 +-
 .../common/channel/ChannelAsyncInputStream.java |  24 +-
 .../channel/ChannelAsyncOutputStream.java       |   4 +-
 .../common/forward/DefaultTcpipForwarder.java   |   4 +-
 .../apache/sshd/common/forward/SocksProxy.java  |   4 +-
 .../sshd/common/future/AbstractSshFuture.java   | 179 ++++++++
 .../common/future/DefaultKeyExchangeFuture.java |  17 +-
 .../sshd/common/future/DefaultSshFuture.java    | 157 +------
 .../future/DefaultVerifiableSshFuture.java      |  42 ++
 .../sshd/common/future/KeyExchangeFuture.java   |  32 +-
 .../apache/sshd/common/future/SshFuture.java    |  71 +--
 .../sshd/common/future/SshFutureListener.java   |   1 +
 .../sshd/common/future/VerifiableFuture.java    |  63 +++
 .../sshd/common/future/WaitableFuture.java      | 106 +++++
 .../common/io/AbstractIoServiceFactory.java     |   4 +-
 .../sshd/common/io/AbstractIoWriteFuture.java   |  20 +-
 .../org/apache/sshd/common/io/IoReadFuture.java |  28 +-
 .../apache/sshd/common/io/IoWriteFuture.java    |  20 +-
 .../apache/sshd/common/io/mina/MinaService.java |   4 +-
 .../apache/sshd/common/io/mina/MinaSession.java |   7 +-
 .../apache/sshd/common/io/nio2/Nio2Service.java |   4 +-
 .../apache/sshd/common/io/nio2/Nio2Session.java |   4 +-
 .../session/AbstractConnectionService.java      |   4 +-
 .../sshd/common/session/AbstractSession.java    |   4 +-
 .../apache/sshd/common/util/CloseableUtils.java | 450 -------------------
 .../util/closeable/AbstractCloseable.java       | 138 ++++++
 .../util/closeable/AbstractInnerCloseable.java  |  55 +++
 .../sshd/common/util/closeable/Builder.java     | 115 +++++
 .../common/util/closeable/CloseableUtils.java   |  58 +++
 .../common/util/closeable/FuturesCloseable.java |  77 ++++
 .../common/util/closeable/IoBaseCloseable.java  |  49 ++
 .../util/closeable/ParallelCloseable.java       |  70 +++
 .../util/closeable/SequentialCloseable.java     |  71 +++
 .../common/util/closeable/SimpleCloseable.java  |  60 +++
 .../sshd/server/channel/ChannelSession.java     |   4 +-
 .../server/session/ServerUserAuthService.java   |   4 +-
 .../sshd/server/x11/X11ForwardSupport.java      |   4 +-
 .../org/apache/sshd/AuthenticationTest.java     |  25 +-
 .../apache/sshd/SinglePublicKeyAuthTest.java    |   6 +-
 .../sshd/client/subsystem/sftp/SftpTest.java    |   4 +
 .../sshd/common/util/CloseableUtilsTest.java    | 131 ------
 .../util/closeable/CloseableUtilsTest.java      | 131 ++++++
 .../deprecated/ClientUserAuthServiceOld.java    |   4 +-
 .../java/org/apache/sshd/util/test/Utils.java   |   3 +-
 55 files changed, 1353 insertions(+), 1095 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java b/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java
index bdb3483..b1ad269 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java
@@ -23,12 +23,12 @@ import java.io.IOException;
 import org.apache.sshd.agent.SshAgentServer;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.session.ConnectionService;
-import org.apache.sshd.common.util.CloseableUtils;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 
 /**
  * The server side fake agent, acting as an agent, but actually forwarding the requests to the auth channel on the client side.
  */
-public class AgentForwardSupport extends CloseableUtils.AbstractCloseable {
+public class AgentForwardSupport extends AbstractCloseable {
 
     private final ConnectionService service;
     private String agentId;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index e0ad99c..285a8e1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -645,7 +645,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
             });
 
             // TODO use a configurable wait time
-            ClientSession session = client.connect(login, host, port).await().getSession();
+            ClientSession session = client.connect(login, host, port).verify().getSession();
             try {
                 session.auth().verify();    // TODO use a configurable wait time
                 return session;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/future/AuthFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/AuthFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/AuthFuture.java
index 5170493..6859966 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/future/AuthFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/future/AuthFuture.java
@@ -18,46 +18,21 @@
  */
 package org.apache.sshd.client.future;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.future.VerifiableFuture;
 
 /**
  * An {@link SshFuture} for asynchronous authentication requests.
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public interface AuthFuture extends SshFuture<AuthFuture> {
-    /**
-     * Wait and verify that the authentication succeeded.
-     *
-     * @throws IOException if the authentication failed for any reason
-     */
-    void verify() throws IOException;
-
-    /**
-     * Wait and verify that the authentication succeeded within the specified timeout.
-     *
-     * @param timeout   The number of time units
-     * @param unit      The {@link TimeUnit} for the timeout
-     * @throws IOException if the authentication failed for any reason
-     */
-    void verify(long timeout, TimeUnit unit) throws IOException;
-
+public interface AuthFuture extends SshFuture<AuthFuture>, VerifiableFuture<AuthFuture> {
     /**
-     * Wait and verify that the authentication succeeded within the specified timeout.
+     * Returns the cause of the authentication failure.
      *
-     * @param timeoutMillis Timeout in milliseconds
-     * @throws IOException if the authentication failed for any reason
-     */
-    void verify(long timeoutMillis) throws IOException;
-
-    /**
-     * Returns the cause of the connection failure.
-     *
-     * @return <code>null</code> if the connect operation is not finished yet,
-     * or if the connection attempt is successful.
+     * @return <code>null</code> if the authentication operation is not finished yet,
+     * or if the connection attempt is successful (use {@link #isDone()} to distinguish
+     * between the two).
      */
     Throwable getException();
 
@@ -100,5 +75,4 @@ public interface AuthFuture extends SshFuture<AuthFuture> {
      * this future.
      */
     void cancel();
-
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/future/ConnectFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/ConnectFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/ConnectFuture.java
index a4f4098..9c73009 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/future/ConnectFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/future/ConnectFuture.java
@@ -18,50 +18,22 @@
  */
 package org.apache.sshd.client.future;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.future.VerifiableFuture;
 
 /**
  * An {@link SshFuture} for asynchronous connections requests.
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public interface ConnectFuture extends SshFuture<ConnectFuture> {
-
+public interface ConnectFuture extends SshFuture<ConnectFuture>, VerifiableFuture<ConnectFuture> {
     /**
      * @return The referenced {@link ClientSession}
      */
     ClientSession getSession();
 
     /**
-     * Wait and verify that connection succeeded within specified timeout
-     *
-     * @param count The number of time units to wait
-     * @param unit  The {@link TimeUnit} for waiting
-     * @return The {@link ConnectFuture}
-     * @throws IOException If failed to verify the request on time
-     */
-    ConnectFuture verify(long count, TimeUnit unit) throws IOException;
-
-    /**
-     * @param timeout The wait timeout in milliseconds
-     * @return The {@link ConnectFuture}
-     * @throws IOException If failed to verify the request on time
-     */
-    ConnectFuture verify(long timeout) throws IOException;
-
-    /**
-     * Returns the cause of the connection failure.
-     *
-     * @return <code>null</code> if the connect operation is not finished yet,
-     * or if the connection attempt is successful.
-     */
-    Throwable getException();
-
-    /**
      * @return <code>true</code> if the connect operation is finished successfully.
      */
     boolean isConnected();
@@ -82,6 +54,15 @@ public interface ConnectFuture extends SshFuture<ConnectFuture> {
     void setSession(ClientSession session);
 
     /**
+     * Returns the cause of the connection failure.
+     *
+     * @return <code>null</code> if the connect operation is not finished yet,
+     * or if the connection attempt is successful (use {@link #isDone()} to
+     * distinguish between the two)
+     */
+    Throwable getException();
+
+    /**
      * Sets the exception caught due to connection failure and notifies all
      * threads waiting for this future.  This method is invoked by SSHD
      * internally.  Please do not call this method directly.
@@ -95,5 +76,4 @@ public interface ConnectFuture extends SshFuture<ConnectFuture> {
      * this future.
      */
     void cancel();
-
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java
index ff68d19..ca83826 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java
@@ -19,10 +19,9 @@
 package org.apache.sshd.client.future;
 
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.future.DefaultSshFuture;
+import org.apache.sshd.common.future.DefaultVerifiableSshFuture;
 import org.apache.sshd.common.util.ValidateUtils;
 
 
@@ -31,27 +30,19 @@ import org.apache.sshd.common.util.ValidateUtils;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class DefaultAuthFuture extends DefaultSshFuture<AuthFuture> implements AuthFuture {
+public class DefaultAuthFuture extends DefaultVerifiableSshFuture<AuthFuture> implements AuthFuture {
     public DefaultAuthFuture(Object lock) {
         super(lock);
     }
 
-    @Override   // TODO for JDK-8 make this a default method
-    public void verify() throws IOException {
-        verify(Long.MAX_VALUE);
-    }
-
-    @Override   // TODO for JDK-8 make this a default method
-    public void verify(long timeout, TimeUnit unit) throws IOException {
-        verify(unit.toMillis(timeout));
-    }
-
     @Override
-    public void verify(long timeoutMillis) throws IOException {
+    public AuthFuture verify(long timeoutMillis) throws IOException {
         Boolean result = verifyResult(Boolean.class, timeoutMillis);
         if (!result.booleanValue()) {
             throw new SshException("Authentication failed");
         }
+
+        return this;
     }
 
     @Override   // TODO for JDK-8 make this a default method

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java
index 39165f8..fd896ad 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java
@@ -19,11 +19,10 @@
 package org.apache.sshd.client.future;
 
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.RuntimeSshException;
-import org.apache.sshd.common.future.DefaultSshFuture;
+import org.apache.sshd.common.future.DefaultVerifiableSshFuture;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.util.ValidateUtils;
 
@@ -32,17 +31,12 @@ import org.apache.sshd.common.util.ValidateUtils;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class DefaultConnectFuture extends DefaultSshFuture<ConnectFuture> implements ConnectFuture {
+public class DefaultConnectFuture extends DefaultVerifiableSshFuture<ConnectFuture> implements ConnectFuture {
     public DefaultConnectFuture(Object lock) {
         super(lock);
     }
 
     @Override   // TODO in JDK-8 make this a default method
-    public ConnectFuture verify(long count, TimeUnit unit) throws IOException {
-        return verify(unit.toMillis(count));
-    }
-
-    @Override   // TODO in JDK-8 make this a default method
     public ConnectFuture verify(long timeout) throws IOException {
         long startTime = System.nanoTime();
         ClientSession session = verifyResult(ClientSession.class, timeout);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultOpenFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultOpenFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultOpenFuture.java
index 0e2ba24..0f3bc2e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultOpenFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultOpenFuture.java
@@ -19,10 +19,9 @@
 package org.apache.sshd.client.future;
 
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.future.DefaultSshFuture;
+import org.apache.sshd.common.future.DefaultVerifiableSshFuture;
 import org.apache.sshd.common.util.ValidateUtils;
 
 /**
@@ -30,27 +29,19 @@ import org.apache.sshd.common.util.ValidateUtils;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class DefaultOpenFuture extends DefaultSshFuture<OpenFuture> implements OpenFuture {
+public class DefaultOpenFuture extends DefaultVerifiableSshFuture<OpenFuture> implements OpenFuture {
     public DefaultOpenFuture(Object lock) {
         super(lock);
     }
 
     @Override   // TODO for JDK-8 make this a default method
-    public void verify() throws IOException {
-        verify(Long.MAX_VALUE);
-    }
-
-    @Override   // TODO for JDK-8 make this a default method
-    public void verify(long timeout, TimeUnit unit) throws IOException {
-        verify(unit.toMillis(timeout));
-    }
-
-    @Override   // TODO for JDK-8 make this a default method
-    public void verify(long timeoutMillis) throws IOException {
+    public OpenFuture verify(long timeoutMillis) throws IOException {
         Boolean result = verifyResult(Boolean.class, timeoutMillis);
         if (!result.booleanValue()) {
             throw new SshException("Channel opening failed");
         }
+
+        return this;
     }
 
     @Override   // TODO for JDK-8 make this a default method

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/future/OpenFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/OpenFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/OpenFuture.java
index 3327888..e5cfe71 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/future/OpenFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/future/OpenFuture.java
@@ -18,46 +18,21 @@
  */
 package org.apache.sshd.client.future;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.future.VerifiableFuture;
 
 /**
  * An {@link SshFuture} for asynchronous channel opening requests.
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public interface OpenFuture extends SshFuture<OpenFuture> {
-    /**
-     * Wait and verify that the channel has been successfully opened.
-     *
-     * @throws IOException if the action failed for any reason
-     */
-    void verify() throws IOException;
-
-    /**
-     * Wait and verify that the channel has been successfully opened.
-     *
-     * @param timeout The number of time units to wait
-     * @param unit    The wait {@link TimeUnit}
-     * @throws IOException If failed to verify successfully on time
-     */
-    void verify(long timeout, TimeUnit unit) throws IOException;
-
-    /**
-     * Wait and verify that the channel has been successfully opened.
-     *
-     * @param timeoutMillis Wait timeout in milliseconds
-     * @throws IOException If failed to verify successfully on time
-     */
-    void verify(long timeoutMillis) throws IOException;
-
+public interface OpenFuture extends SshFuture<OpenFuture>, VerifiableFuture<OpenFuture> {
     /**
      * Returns the cause of the connection failure.
      *
      * @return <code>null</code> if the connect operation is not finished yet,
-     * or if the connection attempt is successful.
+     * or if the connection attempt is successful (use {@link #isDone()} to
+     * distinguish between the two).
      */
     Throwable getException();
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
index 0ef430c..96988ef 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
@@ -35,16 +35,16 @@ import org.apache.sshd.common.Service;
 import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 
 /**
  * Client side <code>ssh-auth</code> service.
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class ClientUserAuthService extends CloseableUtils.AbstractCloseable implements Service {
+public class ClientUserAuthService extends AbstractCloseable implements Service {
 
     /**
      * The AuthFuture that is being used by the current auth request.  This encodes the state.

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
index 4d70ac0..8ac555d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
@@ -49,9 +49,9 @@ import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.SessionListener;
 import org.apache.sshd.common.session.SessionTimeoutListener;
 import org.apache.sshd.common.signature.Signature;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.EventListenerUtils;
 import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
 import org.apache.sshd.common.util.threads.ThreadUtils;
 import org.apache.sshd.server.forward.ForwardingFilter;
 
@@ -61,7 +61,7 @@ import org.apache.sshd.server.forward.ForwardingFilter;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public abstract class AbstractFactoryManager
-        extends CloseableUtils.AbstractInnerCloseable
+        extends AbstractInnerCloseable
         implements FactoryManager, KeyPairProviderHolder {
 
     protected Map<String, Object> properties = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index 19ef0cb..9890c98 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -38,7 +38,6 @@ import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoWriteFuture;
 import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.EventListenerUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.Int2IntFunction;
@@ -46,6 +45,8 @@ import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.BufferUtils;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
+import org.apache.sshd.common.util.closeable.IoBaseCloseable;
 import org.apache.sshd.common.util.io.IoUtils;
 import org.apache.sshd.common.util.threads.ExecutorServiceConfigurer;
 
@@ -55,7 +56,7 @@ import org.apache.sshd.common.util.threads.ExecutorServiceConfigurer;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public abstract class AbstractChannel
-        extends CloseableUtils.AbstractInnerCloseable
+        extends AbstractInnerCloseable
         implements Channel, ExecutorServiceConfigurer {
 
     public static final int DEFAULT_WINDOW_SIZE = 0x200000;
@@ -275,7 +276,7 @@ public abstract class AbstractChannel
         return new GracefulChannelCloseable();
     }
 
-    public class GracefulChannelCloseable extends CloseableUtils.IoBaseCloseable {
+    public class GracefulChannelCloseable extends IoBaseCloseable {
 
         private final AtomicBoolean closing = new AtomicBoolean(false);
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
index 775e335..b035c1d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
@@ -27,13 +27,13 @@ import org.apache.sshd.common.Closeable;
 import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
 
 /**
  * An IoOutputStream capable of queuing write requests
  */
-public class BufferedIoOutputStream extends CloseableUtils.AbstractInnerCloseable implements IoOutputStream {
+public class BufferedIoOutputStream extends AbstractInnerCloseable implements IoOutputStream {
 
     private final IoOutputStream out;
     private final Queue<IoWriteFutureImpl> writes = new ConcurrentLinkedQueue<IoWriteFutureImpl>();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
index eaef733..11be85b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
@@ -19,24 +19,22 @@
 package org.apache.sshd.common.channel;
 
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.sshd.common.RuntimeSshException;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.future.CloseFuture;
-import org.apache.sshd.common.future.DefaultSshFuture;
+import org.apache.sshd.common.future.DefaultVerifiableSshFuture;
 import org.apache.sshd.common.io.IoInputStream;
 import org.apache.sshd.common.io.IoReadFuture;
 import org.apache.sshd.common.io.ReadPendingException;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.Readable;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class ChannelAsyncInputStream extends CloseableUtils.AbstractCloseable implements IoInputStream {
+public class ChannelAsyncInputStream extends AbstractCloseable implements IoInputStream {
 
     private final Channel channel;
     private final Buffer buffer = new ByteArrayBuffer();
@@ -125,7 +123,7 @@ public class ChannelAsyncInputStream extends CloseableUtils.AbstractCloseable im
         return "ChannelAsyncInputStream[" + channel + "]";
     }
 
-    public static class IoReadFutureImpl extends DefaultSshFuture<IoReadFuture> implements IoReadFuture {
+    public static class IoReadFutureImpl extends DefaultVerifiableSshFuture<IoReadFuture> implements IoReadFuture {
         private final Buffer buffer;
 
         public IoReadFutureImpl(Buffer buffer) {
@@ -139,23 +137,15 @@ public class ChannelAsyncInputStream extends CloseableUtils.AbstractCloseable im
         }
 
         @Override   // TODO for JDK-8 make this a default method
-        public void verify() throws IOException {
-            verify(Long.MAX_VALUE);
-        }
-
-        @Override   // TODO for JDK-8 make this a default method
-        public void verify(long timeout, TimeUnit unit) throws IOException {
-            verify(unit.toMillis(timeout));
-        }
-
-        @Override   // TODO for JDK-8 make this a default method
-        public void verify(long timeoutMillis) throws IOException {
+        public IoReadFuture verify(long timeoutMillis) throws IOException {
             long startTime = System.nanoTime();
             Number result = verifyResult(Number.class, timeoutMillis);
             long endTime = System.nanoTime();
             if (log.isDebugEnabled()) {
                 log.debug("Read " + result + " bytes after " + (endTime - startTime) + " nanos");
             }
+
+            return this;
         }
 
         @Override   // TODO for JDK-8 make this a default method

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
index dd25023..c5c9c17 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
@@ -28,10 +28,10 @@ import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.io.IoWriteFuture;
 import org.apache.sshd.common.io.WritePendingException;
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 
-public class ChannelAsyncOutputStream extends CloseableUtils.AbstractCloseable implements IoOutputStream {
+public class ChannelAsyncOutputStream extends AbstractCloseable implements IoOutputStream {
 
     private final Channel channel;
     private final byte cmd;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
index e286b66..4df14c4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
@@ -43,12 +43,12 @@ import org.apache.sshd.common.io.IoServiceFactory;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.Readable;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
 import org.apache.sshd.server.forward.ForwardingFilter;
 
 /**
@@ -56,7 +56,7 @@ import org.apache.sshd.server.forward.ForwardingFilter;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable implements TcpipForwarder {
+public class DefaultTcpipForwarder extends AbstractInnerCloseable implements TcpipForwarder {
 
     private final ConnectionService service;
     private final IoHandlerFactory socksProxyIoHandlerFactory = new IoHandlerFactory() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
index bee390c..b8365da 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
@@ -30,9 +30,9 @@ import org.apache.sshd.common.future.SshFutureListener;
 import org.apache.sshd.common.io.IoHandler;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.session.ConnectionService;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 
 /**
  * SOCKS proxy server, supporting simple socks4/5 protocols.
@@ -40,7 +40,7 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  * @see <A HREF="https://en.wikipedia.org/wiki/SOCKS">SOCKS Wikipedia</A>
  */
-public class SocksProxy extends CloseableUtils.AbstractCloseable implements IoHandler {
+public class SocksProxy extends AbstractCloseable implements IoHandler {
 
     private final ConnectionService service;
     private final Map<IoSession, Proxy> proxies = new ConcurrentHashMap<IoSession, Proxy>();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/AbstractSshFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/AbstractSshFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/AbstractSshFuture.java
new file mode 100644
index 0000000..68a0214
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/AbstractSshFuture.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.future;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.io.StreamCorruptedException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.sshd.common.SshException;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractSshFuture<T extends SshFuture> extends AbstractLoggingBean implements SshFuture<T> {
+    /**
+     * A default value to indicate the future has been canceled
+     */
+    protected static final Object CANCELED = new Object();
+
+    /**
+     * A value indicating a {@code null} value
+     */
+    protected static final Object NULL = new Object();
+
+    protected AbstractSshFuture() {
+        super();
+    }
+
+    @Override   // TODO make this a default method in JDK-8
+    public boolean await() throws IOException {
+        return await(Long.MAX_VALUE);
+    }
+
+    @Override   // TODO make this a default method in JDK-8
+    public boolean await(long timeout, TimeUnit unit) throws IOException {
+        return await(unit.toMillis(timeout));
+    }
+
+    @Override
+    public boolean await(long timeoutMillis) throws IOException {
+        return await0(timeoutMillis, true) != null;
+    }
+
+    @Override   // TODO make this a default method in JDK-8
+    public boolean awaitUninterruptibly() {
+        return awaitUninterruptibly(Long.MAX_VALUE);
+    }
+
+    @Override   // TODO make this a default method in JDK-8
+    public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
+        return awaitUninterruptibly(unit.toMillis(timeout));
+    }
+
+    @Override
+    public boolean awaitUninterruptibly(long timeoutMillis) {
+        try {
+            return await0(timeoutMillis, false) != null;
+        } catch (InterruptedIOException e) {
+            // TODO for JDK-8 use the 2-args constructors
+            throw (InternalError) new InternalError("Unexpected interrupted exception wile awaitUninterruptibly "
+                    + timeoutMillis + " msec.: " + e.getMessage()).initCause(e);
+        }
+    }
+
+    /**
+     * <P>Waits (interruptible) for the specified timeout (msec.) and then checks
+     * the result:</P>
+     * <UL>
+     * <LI><P>
+     * If result is {@code null} then timeout is assumed to have expired - throw
+     * an appropriate {@link IOException}
+     * </P></LI>
+     *
+     * <LI><P>
+     * If the result is of the expected type, then cast and return it
+     * </P></LI>
+     *
+     * <LI><P>
+     * If the result is an {@link IOException} then re-throw it
+     * </P></LI>
+     *
+     * <LI><P>
+     * If the result is a {@link Throwable} then throw an {@link IOException}
+     * whose cause is the original exception
+     * </P></LI>
+     *
+     * <LI><P>
+     * Otherwise (should never happen), throw a {@link StreamCorruptedException}
+     * with the name of the result type
+     * </P></LI>
+     * </UL>
+     *
+     * @param <R>          The generic result type
+     * @param expectedType The expected result type
+     * @param timeout      The timeout (millis) to wait for a result
+     * @return The (never {@code null}) result
+     * @throws IOException If failed to retrieve the expected result on time
+     */
+    protected <R> R verifyResult(Class<? extends R> expectedType, long timeout) throws IOException {
+        Object value = await0(timeout, true);
+        if (value == null) {
+            throw new SshException("Failed to get operation result within specified timeout: " + timeout);
+        }
+
+        Class<?> actualType = value.getClass();
+        if (expectedType.isAssignableFrom(actualType)) {
+            return expectedType.cast(value);
+        }
+
+        if (Throwable.class.isAssignableFrom(actualType)) {
+            Throwable t = GenericUtils.peelException((Throwable) value);
+            if (t != value) {
+                value = t;
+                actualType = value.getClass();
+            }
+
+            if (IOException.class.isAssignableFrom(actualType)) {
+                throw (IOException) value;
+            }
+
+            throw new SshException("Failed (" + t.getClass().getSimpleName() + ") to execute: " + t.getMessage(), GenericUtils.resolveExceptionCause(t));
+        } else {    // what else can it be ????
+            throw new StreamCorruptedException("Unknown result type: " + actualType.getName());
+        }
+    }
+
+    /**
+     * Wait for the Future to be ready. If the requested delay is 0 or
+     * negative, this method returns immediately.
+     *
+     * @param timeoutMillis The delay we will wait for the Future to be ready
+     * @param interruptable Tells if the wait can be interrupted or not.
+     *                      If {@code true} and the thread is interrupted then an {@link InterruptedIOException}
+     *                      is thrown.
+     * @return The non-{@code null} result object if the Future is ready,
+     * {@code null} if the timeout expired and no result was received
+     * @throws InterruptedIOException If the thread has been interrupted
+     *                                when it's not allowed.
+     */
+    protected abstract Object await0(long timeoutMillis, boolean interruptable) throws InterruptedIOException;
+
+    @SuppressWarnings("unchecked")
+    protected SshFutureListener<T> asListener(Object o) {
+        return (SshFutureListener<T>) o;
+    }
+
+    protected void notifyListener(SshFutureListener<T> l) {
+        try {
+            l.operationComplete(asT());
+        } catch (Throwable t) {
+            log.warn("Listener threw an exception", t);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected T asT() {
+        return (T) this;
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultKeyExchangeFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultKeyExchangeFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultKeyExchangeFuture.java
index 5d89f99..9aceaa5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultKeyExchangeFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultKeyExchangeFuture.java
@@ -20,34 +20,25 @@
 package org.apache.sshd.common.future;
 
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.sshd.common.SshException;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class DefaultKeyExchangeFuture extends DefaultSshFuture<KeyExchangeFuture>implements KeyExchangeFuture {
+public class DefaultKeyExchangeFuture extends DefaultVerifiableSshFuture<KeyExchangeFuture> implements KeyExchangeFuture {
     public DefaultKeyExchangeFuture(Object lock) {
         super(lock);
     }
 
     @Override   // TODO for JDK-8 make this a default method
-    public void verify() throws IOException {
-        verify(Long.MAX_VALUE);
-    }
-
-    @Override   // TODO for JDK-8 make this a default method
-    public void verify(long timeout, TimeUnit unit) throws IOException {
-        verify(unit.toMillis(timeout));
-    }
-
-    @Override   // TODO for JDK-8 make this a default method
-    public void verify(long timeoutMillis) throws IOException {
+    public KeyExchangeFuture verify(long timeoutMillis) throws IOException {
         Boolean result = verifyResult(Boolean.class, timeoutMillis);
         if (!result.booleanValue()) {
             throw new SshException("Key exchange failed");
         }
+
+        return this;
     }
 
     @Override   // TODO for JDK-8 make this a default method

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
index 812e06e..89d5768 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
@@ -18,32 +18,17 @@
  */
 package org.apache.sshd.common.future;
 
-import java.io.IOException;
 import java.io.InterruptedIOException;
-import java.io.StreamCorruptedException;
 import java.lang.reflect.Array;
-import java.util.concurrent.TimeUnit;
 
-import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
-import org.apache.sshd.common.util.logging.AbstractLoggingBean;
 
 /**
  * A default implementation of {@link SshFuture}.
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean implements SshFuture<T> {
-    /**
-     * A default value to indicate the future has been canceled
-     */
-    private static final Object CANCELED = new Object();
-    /**
-     * A value indicating a null
-     */
-    private static final Object NULL = new Object();
-
+public class DefaultSshFuture<T extends SshFuture> extends AbstractSshFuture<T> {
     /**
      * A lock used by the wait() method
      */
@@ -62,126 +47,6 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
     }
 
     @Override
-    public T await() throws IOException {
-        if (await(Long.MAX_VALUE)) {
-            return asT();
-        } else {
-            throw new SshException("No result while await completion");
-        }
-    }
-
-    @Override
-    public boolean await(long timeout, TimeUnit unit) throws IOException {
-        return await(unit.toMillis(timeout));
-    }
-
-    @Override
-    public boolean await(long timeoutMillis) throws IOException {
-        return await0(timeoutMillis, true) != null;
-    }
-
-    @Override
-    public T awaitUninterruptibly() {
-        try {
-            await0(Long.MAX_VALUE, false);
-        } catch (InterruptedIOException ie) {
-            // Do nothing : this catch is just mandatory by contract
-        }
-
-        return asT();
-    }
-
-    @Override
-    public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
-        return awaitUninterruptibly(unit.toMillis(timeout));
-    }
-
-    @Override
-    public boolean awaitUninterruptibly(long timeoutMillis) {
-        try {
-            return await0(timeoutMillis, false) != null;
-        } catch (InterruptedIOException e) {
-            // TODO for JDK-8 use the 2-args constructors
-            throw (InternalError) new InternalError("Unexpected interrupted exception wile awaitUninterruptibly "
-                    + timeoutMillis + " msec.: " + e.getMessage()).initCause(e);
-        }
-    }
-
-    /**
-     * <P>Waits (interruptible) for the specified timeout (msec.) and then checks
-     * the result:</P>
-     * <UL>
-     * <LI><P>
-     * If result is {@code null} then timeout is assumed to have expired - throw
-     * an appropriate {@link IOException}
-     * </P></LI>
-     *
-     * <LI><P>
-     * If the result is of the expected type, then cast and return it
-     * </P></LI>
-     *
-     * <LI><P>
-     * If the result is an {@link IOException} then re-throw it
-     * </P></LI>
-     *
-     * <LI><P>
-     * If the result is a {@link Throwable} then throw an {@link IOException}
-     * whose cause is the original exception
-     * </P></LI>
-     *
-     * <LI><P>
-     * Otherwise (should never happen), throw a {@link StreamCorruptedException}
-     * with the name of the result type
-     * </P></LI>
-     * </UL>
-     *
-     * @param <R>          The generic result type
-     * @param expectedType The expected result type
-     * @param timeout      The timeout (millis) to wait for a result
-     * @return The (never {@code null}) result
-     * @throws IOException If failed to retrieve the expected result on time
-     */
-    protected <R> R verifyResult(Class<? extends R> expectedType, long timeout) throws IOException {
-        Object value = await0(timeout, true);
-        if (value == null) {
-            throw new SshException("Failed to get operation result within specified timeout: " + timeout);
-        }
-
-        Class<?> actualType = value.getClass();
-        if (expectedType.isAssignableFrom(actualType)) {
-            return expectedType.cast(value);
-        }
-
-        if (Throwable.class.isAssignableFrom(actualType)) {
-            Throwable t = GenericUtils.peelException((Throwable) value);
-            if (t != value) {
-                value = t;
-                actualType = value.getClass();
-            }
-
-            if (IOException.class.isAssignableFrom(actualType)) {
-                throw (IOException) value;
-            }
-
-            throw new SshException("Failed (" + t.getClass().getSimpleName() + ") to execute: " + t.getMessage(), GenericUtils.resolveExceptionCause(t));
-        } else {    // what else can it be ????
-            throw new StreamCorruptedException("Unknown result type: " + actualType.getName());
-        }
-    }
-
-    /**
-     * Wait for the Future to be ready. If the requested delay is 0 or
-     * negative, this method immediately returns.
-     *
-     * @param timeoutMillis The delay we will wait for the Future to be ready
-     * @param interruptable Tells if the wait can be interrupted or not.
-     *                      If {@code true} and the thread is interrupted then an {@link InterruptedIOException}
-     *                      is thrown.
-     * @return The non-{@code null} result object if the Future is ready,
-     * {@code null} if the timeout expired and no result was received
-     * @throws InterruptedIOException If the thread has been interrupted
-     *                                when it's not allowed.
-     */
     protected Object await0(long timeoutMillis, boolean interruptable) throws InterruptedIOException {
         ValidateUtils.checkTrue(timeoutMillis >= 0L, "Negative timeout N/A: %d", timeoutMillis);
         long startTime = System.currentTimeMillis();
@@ -301,7 +166,7 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
         return asT();
     }
 
-    private void notifyListeners() {
+    protected void notifyListeners() {
         // There won't be any visibility problem or concurrent modification
         // because 'ready' flag will be checked against both addListener and
         // removeListener calls.
@@ -320,14 +185,6 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
         }
     }
 
-    private void notifyListener(SshFutureListener<T> l) {
-        try {
-            l.operationComplete(asT());
-        } catch (Throwable t) {
-            log.warn("Listener threw an exception", t);
-        }
-    }
-
     public boolean isCanceled() {
         return getValue() == CANCELED;
     }
@@ -335,14 +192,4 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
     public void cancel() {
         setValue(CANCELED);
     }
-
-    @SuppressWarnings("unchecked")
-    private SshFutureListener<T> asListener(Object o) {
-        return (SshFutureListener<T>) o;
-    }
-
-    @SuppressWarnings("unchecked")
-    private T asT() {
-        return (T) this;
-    }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultVerifiableSshFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultVerifiableSshFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultVerifiableSshFuture.java
new file mode 100644
index 0000000..142457e
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultVerifiableSshFuture.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.future;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class DefaultVerifiableSshFuture<T extends SshFuture> extends DefaultSshFuture<T>implements VerifiableFuture<T> {
+    protected DefaultVerifiableSshFuture(Object lock) {
+        super(lock);
+    }
+
+    @Override   // TODO for JDK-8 make this a default method
+    public T verify() throws IOException {
+        return verify(Long.MAX_VALUE);
+    }
+
+    @Override   // TODO for JDK-8 make this a default method
+    public T verify(long timeout, TimeUnit unit) throws IOException {
+        return verify(unit.toMillis(timeout));
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/KeyExchangeFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/KeyExchangeFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/KeyExchangeFuture.java
index c4f4e1f..933bbf0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/KeyExchangeFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/KeyExchangeFuture.java
@@ -19,42 +19,16 @@
 
 package org.apache.sshd.common.future;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public interface KeyExchangeFuture extends SshFuture<KeyExchangeFuture> {
-    /**
-     * Wait and verify that the exchange has been successful
-     *
-     * @throws IOException if the action failed for any reason
-     */
-    void verify() throws IOException;
-
-    /**
-     * Wait and verify that the exchange has been successful
-     *
-     * @param timeout The number of time units to wait
-     * @param unit    The wait {@link TimeUnit}
-     * @throws IOException If failed to verify successfully on time
-     */
-    void verify(long timeout, TimeUnit unit) throws IOException;
-
-    /**
-     * Wait and verify that the exchange has been successful
-     *
-     * @param timeoutMillis Wait timeout in milliseconds
-     * @throws IOException If failed to verify successfully on time
-     */
-    void verify(long timeoutMillis) throws IOException;
-
+public interface KeyExchangeFuture extends SshFuture<KeyExchangeFuture>, VerifiableFuture<KeyExchangeFuture> {
     /**
      * Returns the cause of the exchange failure.
      *
      * @return <code>null</code> if the exchange operation is not finished yet,
-     * or if the exchange attempt is successful.
+     * or if the connection attempt is successful (use {@link #isDone()} to
+     * distinguish between the two).
      */
     Throwable getException();
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
index b042b1f..27e2a9e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
@@ -18,9 +18,6 @@
  */
 package org.apache.sshd.common.future;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 /**
  * Represents the completion of an asynchronous SSH operation on a given object
  * (it may be an SSH session or an SSH channel).
@@ -28,73 +25,7 @@ import java.util.concurrent.TimeUnit;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public interface SshFuture<T extends SshFuture> {
-
-    /**
-     * Wait for the asynchronous operation to complete.
-     * The attached listeners will be notified when the operation is
-     * completed.
-     *
-     * @return The {@code this} instance
-     * @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
-     *                     if waiting was interrupted
-     */
-    T await() throws IOException;
-
-    /**
-     * Wait for the asynchronous operation to complete with the specified timeout.
-     *
-     * @param timeout   The number of time units to wait
-     * @param unit      The {@link TimeUnit} for waiting
-     * @return {@code true} if the operation is completed.
-     * @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
-     *                     if waiting was interrupted
-     */
-    boolean await(long timeout, TimeUnit unit) throws IOException;
-
-    /**
-     * Wait for the asynchronous operation to complete with the specified timeout.
-     *
-     * @param timeoutMillis Wait time in milliseconds
-     * @return {@code true} if the operation is completed.
-     * @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
-     *                     if waiting was interrupted
-     */
-    boolean await(long timeoutMillis) throws IOException;
-
-    /**
-     * Wait for the asynchronous operation to complete uninterruptibly.
-     * The attached listeners will be notified when the operation is
-     * completed.
-     *
-     * @return the current future
-     */
-    T awaitUninterruptibly();
-
-    /**
-     * Wait for the asynchronous operation to complete with the specified timeout
-     * uninterruptibly.
-     *
-     * @param timeout   The number of time units to wait
-     * @param unit      The {@link TimeUnit} for waiting
-     * @return {@code true} if the operation is completed.
-     */
-    boolean awaitUninterruptibly(long timeout, TimeUnit unit);
-
-    /**
-     * Wait for the asynchronous operation to complete with the specified timeout
-     * uninterruptibly.
-     *
-     * @param timeoutMillis Wait time in milliseconds
-     * @return {@code true} if the operation is finished.
-     */
-    boolean awaitUninterruptibly(long timeoutMillis);
-
-    /**
-     * @return {@code true} if the asynchronous operation is completed.
-     */
-    boolean isDone();
-
+public interface SshFuture<T extends SshFuture> extends WaitableFuture {
     /**
      * Adds an event <tt>listener</tt> which is notified when
      * this future is completed. If the listener is added

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
index c19f53e..44dc8d4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
@@ -26,6 +26,7 @@ import java.util.EventListener;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
+@SuppressWarnings("rawtypes")
 public interface SshFutureListener<T extends SshFuture> extends EventListener {
 
     /**

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java
new file mode 100644
index 0000000..d903d5b
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.future;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Represents an asynchronous operation whose successful result can be
+ * verified somehow. The contract guarantees that if the {@code verifyXXX}
+ * method returns without an exception then the operation was completed
+ * <U>successfully</U>
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface VerifiableFuture<T> {
+    /**
+     * Wait {@link Long.MAX_VALUE} msec. and verify that the operation was successful
+     *
+     * @return The (same) future instance
+     * @throws IOException If failed to verify successfully on time
+     * @see #verify(long)
+     */
+    T verify() throws IOException;
+
+    /**
+     * Wait and verify that the operation was successful
+     *
+     * @param timeout The number of time units to wait
+     * @param unit    The wait {@link TimeUnit}
+     * @return The (same) future instance
+     * @throws IOException If failed to verify successfully on time
+     * @see #verify(long)
+     */
+    T verify(long timeout, TimeUnit unit) throws IOException;
+
+    /**
+     * Wait and verify that the operation was successful
+     *
+     * @param timeoutMillis Wait timeout in milliseconds
+     * @return The (same) future instance
+     * @throws IOException If failed to verify successfully on time
+     */
+    T verify(long timeoutMillis) throws IOException;
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/future/WaitableFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/WaitableFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/WaitableFuture.java
new file mode 100644
index 0000000..d048b75
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/WaitableFuture.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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 org.apache.sshd.common.future;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Represents an asynchronous operation which one can wait for its completion.
+ * <B>Note:</B> the only thing guaranteed is that if {@code true} is returned
+ * from one of the {@code awaitXXX} methods then the operation has completed.
+ * However, the <B>caller</B> has to determine whether it was a successful or
+ * failed completion.
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface WaitableFuture {
+
+    /**
+     * Wait {@link Long.MAX_VALUE} msec. for the asynchronous operation to complete.
+     * The attached listeners will be notified when the operation is
+     * completed.
+     *
+     * @return {@code true} if the operation is completed.
+     * @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
+     *                     if waiting was interrupted
+     * @see #await(long)
+     */
+    boolean await() throws IOException;
+
+    /**
+     * Wait for the asynchronous operation to complete with the specified timeout.
+     *
+     * @param timeout   The number of time units to wait
+     * @param unit      The {@link TimeUnit} for waiting
+     * @return {@code true} if the operation is completed.
+     * @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
+     *                     if waiting was interrupted
+     * @see #await(long)
+     */
+    boolean await(long timeout, TimeUnit unit) throws IOException;
+
+    /**
+     * Wait for the asynchronous operation to complete with the specified timeout.
+     *
+     * @param timeoutMillis Wait time in milliseconds
+     * @return {@code true} if the operation is completed.
+     * @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
+     *                     if waiting was interrupted
+     */
+    boolean await(long timeoutMillis) throws IOException;
+
+    /**
+     * Wait {@link Long.MAX_VALUE} msec. for the asynchronous operation to complete
+     * uninterruptibly. The attached listeners will be notified when the operation is
+     * completed.
+     *
+     * @return {@code true} if the operation is completed.
+     * @see #awaitUninterruptibly(long)
+     */
+    boolean awaitUninterruptibly();
+
+    /**
+     * Wait for the asynchronous operation to complete with the specified timeout
+     * uninterruptibly.
+     *
+     * @param timeout   The number of time units to wait
+     * @param unit      The {@link TimeUnit} for waiting
+     * @return {@code true} if the operation is completed.
+     * @see #awaitUninterruptibly(long)
+     */
+    boolean awaitUninterruptibly(long timeout, TimeUnit unit);
+
+    /**
+     * Wait for the asynchronous operation to complete with the specified timeout
+     * uninterruptibly.
+     *
+     * @param timeoutMillis Wait time in milliseconds
+     * @return {@code true} if the operation is finished.
+     */
+    boolean awaitUninterruptibly(long timeoutMillis);
+
+    /**
+     * @return {@code true} if the asynchronous operation is completed. <B>Note:</B>
+     * it is up to the <B>caller</B> to determine whether it was a successful or
+     * failed completion.
+     */
+    boolean isDone();
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java
index f0feeac..bb1742e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java
@@ -24,13 +24,13 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.util.CloseableUtils;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 import org.apache.sshd.common.util.threads.ExecutorServiceCarrier;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public abstract class AbstractIoServiceFactory extends CloseableUtils.AbstractCloseable implements IoServiceFactory, ExecutorServiceCarrier {
+public abstract class AbstractIoServiceFactory extends AbstractCloseable implements IoServiceFactory, ExecutorServiceCarrier {
 
     private final FactoryManager manager;
     private final ExecutorService executor;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
index c76075e..6b3e905 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
@@ -20,35 +20,25 @@
 package org.apache.sshd.common.io;
 
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.future.DefaultSshFuture;
+import org.apache.sshd.common.future.DefaultVerifiableSshFuture;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public abstract class AbstractIoWriteFuture extends DefaultSshFuture<IoWriteFuture> implements IoWriteFuture {
+public abstract class AbstractIoWriteFuture extends DefaultVerifiableSshFuture<IoWriteFuture> implements IoWriteFuture {
     protected AbstractIoWriteFuture(Object lock) {
         super(lock);
     }
 
     @Override      // TODO for JDK-8 make this a default method
-    public void verify() throws IOException {
-        verify(Long.MAX_VALUE);
-    }
-
-    @Override      // TODO for JDK-8 make this a default method
-    public void verify(long count, TimeUnit unit) throws IOException {
-        verify(unit.toMillis(count));
-    }
-
-    @Override      // TODO for JDK-8 make this a default method
-    public void verify(long timeout) throws IOException {
+    public IoWriteFuture verify(long timeout) throws IOException {
         Boolean result = verifyResult(Boolean.class, timeout);
         if (!result) {
             throw new SshException("Write failed signalled");
         }
+
+        return this;
     }
 
     @Override      // TODO for JDK-8 make this a default method

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
index dc0aedf..e127eee 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
@@ -18,28 +18,24 @@
  */
 package org.apache.sshd.common.io;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.future.VerifiableFuture;
 import org.apache.sshd.common.util.buffer.Buffer;
 
-public interface IoReadFuture extends SshFuture<IoReadFuture> {
-    /**
-     * Wait and verify that the read succeeded.
-     *
-     * @throws IOException if the action failed for any reason
-     */
-    void verify() throws IOException;
-
-    void verify(long timeout, TimeUnit unit) throws IOException;
-
-    void verify(long timeoutMillis) throws IOException;
-
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface IoReadFuture extends SshFuture<IoReadFuture>, VerifiableFuture<IoReadFuture> {
     Buffer getBuffer();
 
     int getRead();
 
+    /**
+     * Returns the cause of the read failure.
+     *
+     * @return <code>null</code> if the read operation is not finished yet,
+     * or if the read attempt is successful (use {@link #isDone()} to
+     * distinguish between the two).
+     */
     Throwable getException();
-
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/IoWriteFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoWriteFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoWriteFuture.java
index c010434..95d33bd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoWriteFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoWriteFuture.java
@@ -18,23 +18,10 @@
  */
 package org.apache.sshd.common.io;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.sshd.common.future.SshFuture;
+import org.apache.sshd.common.future.VerifiableFuture;
 
-public interface IoWriteFuture extends SshFuture<IoWriteFuture> {
-    /**
-     * Wait and verify that the write succeeded.
-     *
-     * @throws IOException if the write failed for any reason
-     */
-    void verify() throws IOException;
-
-    void verify(long count, TimeUnit unit) throws IOException;
-
-    void verify(long timeout) throws IOException;
-
+public interface IoWriteFuture extends SshFuture<IoWriteFuture>, VerifiableFuture<IoWriteFuture> {
     /**
      * @return <tt>true</tt> if the write operation is finished successfully.
      */
@@ -43,7 +30,8 @@ public interface IoWriteFuture extends SshFuture<IoWriteFuture> {
     /**
      * @return the cause of the write failure if and only if the write
      * operation has failed due to an {@link Exception}.  Otherwise,
-     * <tt>null</tt> is returned.
+     * <tt>null</tt> is returned (use {@link #isDone()} to distinguish
+     * between the two.
      */
     Throwable getException();
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
index 98927da..3fff7ac 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
@@ -33,11 +33,11 @@ import org.apache.mina.transport.socket.nio.NioSession;
 import org.apache.sshd.common.Closeable;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.util.CloseableUtils;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 
 /**
  */
-public abstract class MinaService extends CloseableUtils.AbstractCloseable implements org.apache.sshd.common.io.IoService, IoHandler, Closeable {
+public abstract class MinaService extends AbstractCloseable implements org.apache.sshd.common.io.IoService, IoHandler, Closeable {
     protected final FactoryManager manager;
     protected final org.apache.sshd.common.io.IoHandler handler;
     protected final IoProcessor<NioSession> ioProcessor;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java
index 659e04c..dfd0bb2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaSession.java
@@ -30,13 +30,14 @@ import org.apache.sshd.common.io.AbstractIoWriteFuture;
 import org.apache.sshd.common.io.IoService;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
+import org.apache.sshd.common.util.closeable.IoBaseCloseable;
 
 /**
  */
-public class MinaSession extends CloseableUtils.AbstractInnerCloseable implements IoSession {
+public class MinaSession extends AbstractInnerCloseable implements IoSession {
 
     private final MinaService service;
     private final org.apache.mina.core.session.IoSession session;
@@ -87,7 +88,7 @@ public class MinaSession extends CloseableUtils.AbstractInnerCloseable implement
 
     @Override
     protected Closeable getInnerCloseable() {
-        return new CloseableUtils.IoBaseCloseable() {
+        return new IoBaseCloseable() {
             @SuppressWarnings("synthetic-access")
             @Override
             public boolean isClosing() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
index 8b4829b..7d4f1db 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
@@ -34,13 +34,13 @@ import org.apache.sshd.common.FactoryManagerUtils;
 import org.apache.sshd.common.io.IoHandler;
 import org.apache.sshd.common.io.IoService;
 import org.apache.sshd.common.io.IoSession;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
 
 /**
  */
-public abstract class Nio2Service extends CloseableUtils.AbstractInnerCloseable implements IoService {
+public abstract class Nio2Service extends AbstractInnerCloseable implements IoService {
     protected final FactoryManager manager;
     protected final IoHandler handler;
     protected final Map<Long, IoSession> sessions;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
index be9b8ed..9f5f09c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
@@ -37,13 +37,13 @@ import org.apache.sshd.common.io.IoHandler;
 import org.apache.sshd.common.io.IoService;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.Readable;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractCloseable;
 
 /**
  */
-public class Nio2Session extends CloseableUtils.AbstractCloseable implements IoSession {
+public class Nio2Session extends AbstractCloseable implements IoSession {
 
     public static final int DEFAULT_READBUF_SIZE = 32 * 1024;
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
index 4ed1df5..b38a8a3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
@@ -39,11 +39,11 @@ import org.apache.sshd.common.channel.RequestHandler;
 import org.apache.sshd.common.forward.TcpipForwarder;
 import org.apache.sshd.common.forward.TcpipForwarderFactory;
 import org.apache.sshd.common.future.SshFutureListener;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.Int2IntFunction;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
 import org.apache.sshd.server.channel.OpenChannelException;
 import org.apache.sshd.server.x11.X11ForwardSupport;
 
@@ -66,7 +66,7 @@ import static org.apache.sshd.common.SshConstants.SSH_MSG_REQUEST_SUCCESS;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public abstract class AbstractConnectionService extends CloseableUtils.AbstractInnerCloseable implements ConnectionService {
+public abstract class AbstractConnectionService extends AbstractInnerCloseable implements ConnectionService {
     /**
      * Property that can be used to configure max. allowed concurrent active channels
      *

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d39433b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
index aa78c9c..cdc41b7 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
@@ -58,7 +58,6 @@ import org.apache.sshd.common.kex.KexState;
 import org.apache.sshd.common.kex.KeyExchange;
 import org.apache.sshd.common.mac.Mac;
 import org.apache.sshd.common.random.Random;
-import org.apache.sshd.common.util.CloseableUtils;
 import org.apache.sshd.common.util.EventListenerUtils;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.Readable;
@@ -66,6 +65,7 @@ import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.BufferUtils;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
 
 /**
  * <P>
@@ -82,7 +82,7 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
  *
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public abstract class AbstractSession extends CloseableUtils.AbstractInnerCloseable implements Session {
+public abstract class AbstractSession extends AbstractInnerCloseable implements Session {
 
     public static final String DEFAULT_SSH_VERSION_PREFIX = "SSH-2.0-";