From ac78c175231979c7c5ab361980a233edee7626df Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Sat, 26 Feb 2022 12:46:50 +0100 Subject: [sideband] Ensure last bit of progress channel is written If the last sideband progress message didn't end in \r or \n, there may still be a buffered message at the end of a fetch or push. Ensure that message gets written, too, even if it may be only partial. Bug: 575629 Change-Id: I38edccb5cffb89e00e468480b43c7d951fb63e8e Signed-off-by: Thomas Wolf --- .../eclipse/jgit/transport/SideBandInputStreamTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandInputStreamTest.java index 497f584b5f..7ac83195fb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandInputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandInputStreamTest.java @@ -79,6 +79,8 @@ public class SideBandInputStreamTest { init(packet("message")); assertTrue(sideband.read() < 0); assertEquals("", messages.toString()); + sideband.drainMessages(); + assertEquals("message\n", messages.toString()); } @Test @@ -128,6 +130,8 @@ public class SideBandInputStreamTest { init(packet("message 0%\rmessage 100%")); assertTrue(sideband.read() < 0); assertEquals("message 0%\r", messages.toString()); + sideband.drainMessages(); + assertEquals("message 0%\rmessage 100%\n", messages.toString()); } @Test @@ -135,6 +139,8 @@ public class SideBandInputStreamTest { init(packet("message 0%\nmessage 100%")); assertTrue(sideband.read() < 0); assertEquals("message 0%\n", messages.toString()); + sideband.drainMessages(); + assertEquals("message 0%\nmessage 100%\n", messages.toString()); } @Test @@ -142,6 +148,8 @@ public class SideBandInputStreamTest { init(packet("message 0%\r\nmessage 100%")); assertTrue(sideband.read() < 0); assertEquals("message 0%\r\n", messages.toString()); + sideband.drainMessages(); + assertEquals("message 0%\r\nmessage 100%\n", messages.toString()); } @Test @@ -152,6 +160,8 @@ public class SideBandInputStreamTest { assertEquals("", messages.toString()); assertTrue(sideband.read() < 0); assertEquals("message 0%\r", messages.toString()); + sideband.drainMessages(); + assertEquals("message 0%\rmessage 100%\n", messages.toString()); } @Test @@ -162,6 +172,8 @@ public class SideBandInputStreamTest { assertEquals("", messages.toString()); assertTrue(sideband.read() < 0); assertEquals("message 0%\n", messages.toString()); + sideband.drainMessages(); + assertEquals("message 0%\nmessage 100%\n", messages.toString()); } @Test @@ -172,6 +184,8 @@ public class SideBandInputStreamTest { assertEquals("", messages.toString()); assertTrue(sideband.read() < 0); assertEquals("message 0%\r\n", messages.toString()); + sideband.drainMessages(); + assertEquals("message 0%\r\nmessage 100%\n", messages.toString()); } @Test @@ -197,6 +211,9 @@ public class SideBandInputStreamTest { assertEquals("message 0%\r", messages.toString()); assertTrue(sideband.read() < 0); assertEquals("message 0%\rmessage 10%\r", messages.toString()); + sideband.drainMessages(); + assertEquals("message 0%\rmessage 10%\rmessage 100%\n", + messages.toString()); } private String packet(String data) { -- cgit v1.2.3