Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix warnings in netconf-api and netconf-util
[controller.git]
/
opendaylight
/
netconf
/
netconf-util
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
netconf
/
util
/
handler
/
ssh
/
client
/
SshClientAdapter.java
diff --git
a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/SshClientAdapter.java
b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/SshClientAdapter.java
index 4213fe3e0642db6257b3e655c407a4394785fca3..6350dd154415b510515f919d94c88d06ecac5314 100644
(file)
--- a/
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/SshClientAdapter.java
+++ b/
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/client/SshClientAdapter.java
@@
-27,16
+27,14
@@
import org.opendaylight.controller.netconf.util.handler.ssh.virtualsocket.Virtua
* pipeline.
*/
public class SshClientAdapter implements Runnable {
* pipeline.
*/
public class SshClientAdapter implements Runnable {
+ private static final int BUFFER_SIZE = 1024;
+
private final SshClient sshClient;
private final Invoker invoker;
private final SshClient sshClient;
private final Invoker invoker;
- private SshSession session;
- private InputStream stdOut;
- private InputStream stdErr;
private OutputStream stdIn;
private OutputStream stdIn;
- private Queue<ByteBuf> postponned = new LinkedList<>();
-
+ private Queue<ByteBuf> postponed = new LinkedList<>();
private ChannelHandlerContext ctx;
private ChannelPromise disconnectPromise;
private ChannelHandlerContext ctx;
private ChannelPromise disconnectPromise;
@@
-52,22
+50,22
@@
public class SshClientAdapter implements Runnable {
public void run() {
try {
public void run() {
try {
- session = sshClient.openSession();
+
SshSession
session = sshClient.openSession();
invoker.invoke(session);
invoker.invoke(session);
- stdOut = session.getStdout();
- s
tdErr = s
ession.getStderr();
+
InputStream
stdOut = session.getStdout();
+ session.getStderr();
synchronized (lock) {
stdIn = session.getStdin();
synchronized (lock) {
stdIn = session.getStdin();
- ByteBuf message
= null
;
- while ((message = postpon
n
ed.poll()) != null) {
+ ByteBuf message;
+ while ((message = postponed.poll()) != null) {
writeImpl(message);
}
}
while (stopRequested.get() == false) {
writeImpl(message);
}
}
while (stopRequested.get() == false) {
- byte[] readBuff = new byte[
1024
];
+ byte[] readBuff = new byte[
BUFFER_SIZE
];
int c = stdOut.read(readBuff);
if (c == -1) {
continue;
int c = stdOut.read(readBuff);
if (c == -1) {
continue;
@@
-89,8
+87,9
@@
public class SshClientAdapter implements Runnable {
sshClient.close();
synchronized (lock) {
sshClient.close();
synchronized (lock) {
- if (disconnectPromise != null)
+ if (disconnectPromise != null)
{
ctx.disconnect(disconnectPromise);
ctx.disconnect(disconnectPromise);
+ }
}
}
}
}
}
}
@@
-99,7
+98,7
@@
public class SshClientAdapter implements Runnable {
public void write(ByteBuf message) throws IOException {
synchronized (lock) {
if (stdIn == null) {
public void write(ByteBuf message) throws IOException {
synchronized (lock) {
if (stdIn == null) {
- postpon
n
ed.add(message);
+ postponed.add(message);
return;
}
writeImpl(message);
return;
}
writeImpl(message);
@@
-119,8
+118,10
@@
public class SshClientAdapter implements Runnable {
}
public void start(ChannelHandlerContext ctx) {
}
public void start(ChannelHandlerContext ctx) {
- if (this.ctx != null)
- return; // context is already associated.
+ if (this.ctx != null) {
+ // context is already associated.
+ return;
+ }
this.ctx = ctx;
new Thread(this).start();
}
this.ctx = ctx;
new Thread(this).start();
}