diff --git a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java index 93310e1bc..9fda615cf 100644 --- a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java +++ b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java @@ -126,40 +126,7 @@ public long getId() { @Override protected Closeable getInnerCloseable() { - return new IoBaseCloseable() { - @SuppressWarnings("synthetic-access") - private final DefaultCloseFuture future = new DefaultCloseFuture(MinaSession.this.toString(), futureLock); - - @SuppressWarnings("synthetic-access") - @Override - public boolean isClosing() { - return session.isClosing(); - } - - @SuppressWarnings("synthetic-access") - @Override - public boolean isClosed() { - return !session.isConnected(); - } - - @Override - public void addCloseFutureListener(SshFutureListener listener) { - future.addListener(listener); - } - - @Override - public void removeCloseFutureListener(SshFutureListener listener) { - future.removeListener(listener); - } - - @SuppressWarnings("synthetic-access") - @Override - public org.apache.sshd.common.future.CloseFuture close(boolean immediately) { - org.apache.mina.core.future.CloseFuture cf = immediately ? session.closeNow() : session.closeOnFlush(); - cf.addListener(f -> future.setValue(Boolean.TRUE)); - return future; - } - }; + return new IoSessionCloser(this.toString(), session, futureLock); } // NOTE !!! data buffer may NOT be re-used when method returns - at least until IoWriteFuture is signalled @@ -219,6 +186,45 @@ public void shutdownOutputStream() throws IOException { session.closeOnFlush(); } + private static class IoSessionCloser extends IoBaseCloseable { + + private final DefaultCloseFuture future; + + private final org.apache.mina.core.session.IoSession session; + + IoSessionCloser(String id, org.apache.mina.core.session.IoSession session, Object futureLock) { + this.session = session; + future = new DefaultCloseFuture(id, futureLock); + } + + @Override + public boolean isClosing() { + return session.isClosing(); + } + + @Override + public boolean isClosed() { + return !session.isConnected(); + } + + @Override + public void addCloseFutureListener(SshFutureListener listener) { + future.addListener(listener); + } + + @Override + public void removeCloseFutureListener(SshFutureListener listener) { + future.removeListener(listener); + } + + @Override + public CloseFuture close(boolean immediately) { + org.apache.mina.core.future.CloseFuture cf = immediately ? session.closeNow() : session.closeOnFlush(); + cf.addListener(f -> future.setValue(Boolean.TRUE)); + return future; + } + } + @Override public String toString() { return getClass().getSimpleName()