final NetconfMessage message = new NetconfMessage();
final byte[] buf = new byte[1024];
- //int readByte = 1;
// Read data with timeout
- Callable<Boolean> readTask = new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- int c;
- while ((c = in.read(buf)) > 0) {
- if (c > 0) {
- message.append(buf, 0, c);
- if (message.isCompleted()) {
- break;
- }
- }
+ Callable<Boolean> readTask = () -> {
+ int c;
+ while ((c = in.read(buf)) > 0) {
+ message.append(buf, 0, c);
+ if (message.isCompleted()) {
+ break;
}
-
- if (c < 0) {
- return false;
- }
- return true;
}
+
+ return c >= 0;
};
Future<Boolean> future = executor.submit(readTask);
throw new IOException(e);
}
- if (status == false) {
+ if (!status) {
throw new IOException("Failed to read netconf message");
}