8185719: rmi TestSocketFactory does not flush
authorrriggs
Wed, 02 Aug 2017 13:20:20 -0400
changeset 46056 46c8ef3d3c25
parent 46055 b0170078a6c7
child 46057 ed5d7dfb0a71
8185719: rmi TestSocketFactory does not flush Reviewed-by: lancea, dfuchs
jdk/test/java/rmi/testlibrary/TestSocketFactory.java
--- a/jdk/test/java/rmi/testlibrary/TestSocketFactory.java	Wed Aug 02 08:13:37 2017 -0700
+++ b/jdk/test/java/rmi/testlibrary/TestSocketFactory.java	Wed Aug 02 13:20:20 2017 -0400
@@ -512,9 +512,8 @@
             } else {
                 if (matchIndex > 0) {
                     // mismatch, write out any that matched already
-                    if (matchIndex > 0) // Only non-trivial matches
-                        DEBUG( "Partial match %s matched %d bytes at offset: %d (0x%04x), expected: x%02x, actual: x%02x%n",
-                                name, matchIndex, bytesOut, bytesOut,  matchBytes[matchIndex], b);
+                    DEBUG("Partial match %s matched %d bytes at offset: %d (0x%04x), expected: x%02x, actual: x%02x%n",
+                            name, matchIndex, bytesOut, bytesOut, matchBytes[matchIndex], b);
                     out.write(matchBytes, 0, matchIndex);
                     log.write(matchBytes, 0, matchIndex);
                     bytesOut += matchIndex;
@@ -530,6 +529,19 @@
             }
         }
 
+        public void flush() throws IOException {
+            if (matchIndex > 0) {
+                // write out any that matched already to avoid consumer hang.
+                // Match/replace across a flush is not supported.
+                DEBUG( "Flush partial match %s matched %d bytes at offset: %d (0x%04x)%n",
+                        name, matchIndex, bytesOut, bytesOut);
+                out.write(matchBytes, 0, matchIndex);
+                log.write(matchBytes, 0, matchIndex);
+                bytesOut += matchIndex;
+                matchIndex = 0;
+            }
+        }
+
         @Override
         public String toString() {
             return String.format("%s: Out: (%d)", name, bytesOut);