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 2016/01/31 14:51:30 UTC
mina-sshd git commit: [SSHD-636] Allow to override socket.write
method in Nio2Session
Repository: mina-sshd
Updated Branches:
refs/heads/master e119d07a1 -> 511378eca
[SSHD-636] Allow to override socket.write method in Nio2Session
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/511378ec
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/511378ec
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/511378ec
Branch: refs/heads/master
Commit: 511378eca1597d9b4cc80aa7048f262ec8666b31
Parents: e119d07
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Sun Jan 31 15:51:20 2016 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Sun Jan 31 15:51:20 2016 +0200
----------------------------------------------------------------------
.../java/org/apache/sshd/common/io/nio2/Nio2Session.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/511378ec/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 474251f..13426c6 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
@@ -317,16 +317,16 @@ public class Nio2Session extends AbstractCloseable implements IoSession {
if (future != null) {
if (currentWrite.compareAndSet(null, future)) {
try {
- ByteBuffer buffer = future.getBuffer();
AsynchronousSocketChannel socket = getSocket();
+ ByteBuffer buffer = future.getBuffer();
Nio2CompletionHandler<Integer, Object> handler =
ValidateUtils.checkNotNull(createWriteCycleCompletionHandler(future, socket, buffer),
"No write cycle completion handler created");
- socket.write(buffer, null, handler);
+ doWriteCycle(buffer, handler);
} catch (Throwable e) {
future.setWritten();
if (e instanceof RuntimeException) {
- throw e;
+ throw (RuntimeException) e;
} else {
throw new RuntimeSshException(e);
}
@@ -335,6 +335,11 @@ public class Nio2Session extends AbstractCloseable implements IoSession {
}
}
+ protected void doWriteCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer, Object> completion) {
+ AsynchronousSocketChannel socket = getSocket();
+ socket.write(buffer, null, completion);
+ }
+
protected Nio2CompletionHandler<Integer, Object> createWriteCycleCompletionHandler(
final Nio2DefaultIoWriteFuture future, final AsynchronousSocketChannel socket, final ByteBuffer buffer) {
return new Nio2CompletionHandler<Integer, Object>() {