From df112bc87de92887da0f442630ba42f1f8c2578b Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 28 Apr 2019 12:13:30 +0200 Subject: [PATCH] at last --- .../utils/serial/server/ConnectAction.java | 17 ++++++++--------- .../utils/test_code/SerialServerTest.java | 16 ++++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/be/nikiroo/utils/serial/server/ConnectAction.java b/src/be/nikiroo/utils/serial/server/ConnectAction.java index aafad62..66d43e0 100644 --- a/src/be/nikiroo/utils/serial/server/ConnectAction.java +++ b/src/be/nikiroo/utils/serial/server/ConnectAction.java @@ -252,7 +252,7 @@ abstract class ConnectAction { *

* Will only flush the data if there is contentToSend. * - * @return the answer (which can be NULL) + * @return the answer (which can be NULL if no more content) * * @throws IOException * in case of I/O error @@ -275,11 +275,12 @@ abstract class ConnectAction { } /** - * Read a possibly encrypted line. + * Read a possibly encrypted line, or NULL if no more content. * * @param in * the stream to read from - * @return the unencrypted line + * + * @return the unencrypted line or NULL * * * @throws IOException @@ -288,19 +289,17 @@ abstract class ConnectAction { * in case of crypt error */ private String readLine(NextableInputStream in) throws IOException { - String line = null; if (in.next()) { - line = IOUtils.readSmallStream(in); - } - - if (line != null) { + String line = IOUtils.readSmallStream(in); bytesReceived += line.length(); if (crypt != null) { line = crypt.decrypt64s(line, false); } + + return line; } - return line; + return null; } /** diff --git a/src/be/nikiroo/utils/test_code/SerialServerTest.java b/src/be/nikiroo/utils/test_code/SerialServerTest.java index ceb495b..44d26da 100644 --- a/src/be/nikiroo/utils/test_code/SerialServerTest.java +++ b/src/be/nikiroo/utils/test_code/SerialServerTest.java @@ -19,7 +19,7 @@ class SerialServerTest extends TestLauncher { for (String key : new String[] { null, "some super secret encryption key" }) { // TODO: re-add bridge - for (boolean bridge : new Boolean[] { false }) { + for (boolean bridge : new Boolean[] { false, true }) { final String skey = (key != null ? "(encrypted)" : "(plain text)"); final String sbridge = (bridge ? " with bridge" : ""); @@ -27,13 +27,13 @@ class SerialServerTest extends TestLauncher { addSeries(new SerialServerTest(args, key, skey, bridge, sbridge, "ServerString")); - // addSeries(new SerialServerTest(args, key, skey, bridge, - // sbridge, new Object() { - // @Override - // public String toString() { - // return "ServerObject"; - // } - // })); + addSeries(new SerialServerTest(args, key, skey, bridge, + sbridge, new Object() { + @Override + public String toString() { + return "ServerObject"; + } + })); } } } -- 2.27.0