From bd854040603f0bacf3b559ab4dcc9559b0399e05 Mon Sep 17 00:00:00 2001 From: rriggs Date: Wed, 2 Aug 2017 13:20:20 -0400 Subject: [PATCH] 8185719: rmi TestSocketFactory does not flush Reviewed-by: lancea, dfuchs --- .../rmi/testlibrary/TestSocketFactory.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/rmi/testlibrary/TestSocketFactory.java b/jdk/test/java/rmi/testlibrary/TestSocketFactory.java index b320ef06d0..fe2729e233 100644 --- a/jdk/test/java/rmi/testlibrary/TestSocketFactory.java +++ b/jdk/test/java/rmi/testlibrary/TestSocketFactory.java @@ -512,9 +512,8 @@ public class TestSocketFactory extends RMISocketFactory } 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 class TestSocketFactory extends RMISocketFactory } } + 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); -- GitLab