at last
authorNiki Roo <niki@nikiroo.be>
Sun, 28 Apr 2019 10:13:30 +0000 (12:13 +0200)
committerNiki Roo <niki@nikiroo.be>
Sun, 28 Apr 2019 10:13:30 +0000 (12:13 +0200)
src/be/nikiroo/utils/serial/server/ConnectAction.java
src/be/nikiroo/utils/test_code/SerialServerTest.java

index aafad62facfa5a3a3433df3a7aa54de8f23806b4..66d43e0e757f1912c753796bd95ec9c28cf93f75 100644 (file)
@@ -252,7 +252,7 @@ abstract class ConnectAction {
         * <p>
         * 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;
        }
 
        /**
index ceb495b6f1e0b82391e9952ecb3578070c94f34f..44d26da5e9c438e3d1dfd5bfdc755c7262894f5a 100644 (file)
@@ -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";
+                                                       }
+                                               }));
                        }
                }
        }