From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evrwq-0007hS-KG for guix-patches@gnu.org; Tue, 13 Mar 2018 17:59:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evrwm-00052m-Gt for guix-patches@gnu.org; Tue, 13 Mar 2018 17:59:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:52200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evrwm-00052d-Cf for guix-patches@gnu.org; Tue, 13 Mar 2018 17:59:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1evrwm-0002G5-44 for guix-patches@gnu.org; Tue, 13 Mar 2018 17:59:04 -0400 Subject: bug#30810: [PATCH] gnu: java-jeromq: Fix tests. Resent-To: guix-patches@gnu.org Resent-Message-ID: MIME-Version: 1.0 In-Reply-To: <20180313215416.27638-1-boskovits@gmail.com> References: <20180313215416.27638-1-boskovits@gmail.com> From: =?UTF-8?Q?G=C3=A1bor?= Boskovits Date: Tue, 13 Mar 2018 22:57:55 +0100 Message-ID: Content-Type: multipart/alternative; boundary="001a11446d98e0908a0567525953" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 30810-done@debbugs.gnu.org Cc: =?UTF-8?Q?G=C3=A1bor?= Boskovits --001a11446d98e0908a0567525953 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2018-03-13 22:54 GMT+01:00 G=C3=A1bor Boskovits : > * gnu/packages/patches/java-jeromq-fix-tests.patch: New file. > * gnu/local.mk (dist_patch_DATA): Add it. > * gnu/packages/java.scm (java-jeromq)[source](patches): Add it. > [arguments](#test-exclude): Disable more failing tests. > --- > gnu/local.mk | 1 + > gnu/packages/java.scm | 11 +- > gnu/packages/patches/java-jeromq-fix-tests.patch | 253 > +++++++++++++++++++++++ > 3 files changed, 263 insertions(+), 2 deletions(-) > create mode 100644 gnu/packages/patches/java-jeromq-fix-tests.patch > > diff --git a/gnu/local.mk b/gnu/local.mk > index 9684d949f..2bae3660c 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -782,6 +782,7 @@ dist_patch_DATA =3D > \ > %D%/packages/patches/intltool-perl-compatibility.patch \ > %D%/packages/patches/isl-0.11.1-aarch64-support.patch \ > %D%/packages/patches/jacal-fix-texinfo.patch \ > + %D%/packages/patches/java-jeromq-fix-tests.patch \ > %D%/packages/patches/java-powermock-fix-java-files.patch \ > %D%/packages/patches/java-xerces-bootclasspath.patch \ > %D%/packages/patches/java-xerces-build_dont_unzip.patch \ > diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm > index 0f8c04e8b..85a8c9b3a 100644 > --- a/gnu/packages/java.scm > +++ b/gnu/packages/java.scm > @@ -8117,7 +8117,8 @@ protocol-independent framework to build mail and > messaging applications.") > (file-name (string-append name "-" version "-checkout")) > (sha256 > (base32 > - "1gxkp7lv2ahymgrqdw94ncq54bmp4 > m4sw5m1x9gkp7l5bxn0xsyj")))) > + "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj")) > + (patches (search-patches "java-jeromq-fix-tests.patch")))) > (build-system ant-build-system) > (arguments > `(#:jar-name "java-jeromq.jar" > @@ -8131,7 +8132,13 @@ protocol-independent framework to build mail and > messaging applications.") > ;; Failures > "**/DealerSpecTest.java" > "**/CustomDecoderTest.java" > - "**/CustomEncoderTest.java"))) > + "**/CustomEncoderTest.java" > + "**/ConnectRidTest.java" > + "**/ReqSpecTest.java" > + "**/PushPullSpecTest.java" > + "**/PubSubHwmTest.java" > + "**/RouterSpecTest.java" > + "**/ProxyTest.java"))) > (inputs > `(("java-jnacl" ,java-jnacl))) > (native-inputs > diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch > b/gnu/packages/patches/java-jeromq-fix-tests.patch > new file mode 100644 > index 000000000..5466b9270 > --- /dev/null > +++ b/gnu/packages/patches/java-jeromq-fix-tests.patch > @@ -0,0 +1,253 @@ > +From 5803aadd3f209eba1ffbb2cf7bf16778019dbee1 Mon Sep 17 00:00:00 2001 > +From: fredoboulo > +Date: Fri, 23 Feb 2018 23:55:57 +0100 > +Subject: [PATCH] Fix #524 : V1 and V2 protocol downgrades handle receive= d > data > + in handshake buffer > + > +This patch is upstream pull request, see: > +https://gihub.com/zeromq/jeromq/pull/527. > + > +It is merged on commit c2afa9c, and we can drop it on the > +0.4.4 release. > + > +--- > + src/main/java/zmq/io/StreamEngine.java | 21 ++++++++++-- > + src/test/java/zmq/io/AbstractProtocolVersion.java | 41 > +++++++++++++---------- > + src/test/java/zmq/io/V0ProtocolTest.java | 12 +++++++ > + src/test/java/zmq/io/V1ProtocolTest.java | 16 +++++++-- > + src/test/java/zmq/io/V2ProtocolTest.java | 16 +++++++-- > + 5 files changed, 81 insertions(+), 25 deletions(-) > + > +diff --git a/src/main/java/zmq/io/StreamEngine.java > b/src/main/java/zmq/io/StreamEngine.java > +index b8933c92..fe2f2d8d 100644 > +--- a/src/main/java/zmq/io/StreamEngine.java > ++++ b/src/main/java/zmq/io/StreamEngine.java > +@@ -816,9 +816,7 @@ private boolean handshake() > + assert (bufferSize =3D=3D headerSize); > + > + // Make sure the decoder sees the data we have already > received. > +- greetingRecv.flip(); > +- inpos =3D greetingRecv; > +- insize =3D greetingRecv.limit(); > ++ decodeDataAfterHandshake(0); > + > + // To allow for interoperability with peers that do not > forward > + // their subscriptions, we inject a phantom subscription > message > +@@ -846,6 +844,8 @@ else if (greetingRecv.get(revisionPos) =3D=3D > Protocol.V1.revision) { > + } > + encoder =3D new V1Encoder(errno, Config.OUT_BATCH_SIZE.getV= alue > ()); > + decoder =3D new V1Decoder(errno, Config.IN_BATCH_SIZE.getVa= lue(), > options.maxMsgSize, options.allocator); > ++ > ++ decodeDataAfterHandshake(V2_GREETING_SIZE); > + } > + else if (greetingRecv.get(revisionPos) =3D=3D Protocol.V2.revis= ion) { > + // ZMTP/2.0 framing. > +@@ -859,6 +859,8 @@ else if (greetingRecv.get(revisionPos) =3D=3D > Protocol.V2.revision) { > + } > + encoder =3D new V2Encoder(errno, Config.OUT_BATCH_SIZE.getV= alue > ()); > + decoder =3D new V2Decoder(errno, Config.IN_BATCH_SIZE.getVa= lue(), > options.maxMsgSize, options.allocator); > ++ > ++ decodeDataAfterHandshake(V2_GREETING_SIZE); > + } > + else { > + zmtpVersion =3D Protocol.V3; > +@@ -904,6 +906,19 @@ else if (greetingRecv.get(revisionPos) =3D=3D > Protocol.V2.revision) { > + return true; > + } > + > ++ private void decodeDataAfterHandshake(int greetingSize) > ++ { > ++ final int pos =3D greetingRecv.position(); > ++ if (pos > greetingSize) { > ++ // data is present after handshake > ++ greetingRecv.position(greetingSize).limit(pos); > ++ > ++ // Make sure the decoder sees this extra data. > ++ inpos =3D greetingRecv; > ++ insize =3D greetingRecv.remaining(); > ++ } > ++ } > ++ > + private Msg identityMsg() > + { > + Msg msg =3D new Msg(options.identitySize); > +diff --git a/src/test/java/zmq/io/AbstractProtocolVersion.java > b/src/test/java/zmq/io/AbstractProtocolVersion.java > +index e60db403..aa06b4a7 100644 > +--- a/src/test/java/zmq/io/AbstractProtocolVersion.java > ++++ b/src/test/java/zmq/io/AbstractProtocolVersion.java > +@@ -18,15 +18,18 @@ > + import zmq.SocketBase; > + import zmq.ZError; > + import zmq.ZMQ; > ++import zmq.ZMQ.Event; > + import zmq.util.Utils; > + > + public abstract class AbstractProtocolVersion > + { > ++ protected static final int REPETITIONS =3D 1000; > ++ > + static class SocketMonitor extends Thread > + { > +- private final Ctx ctx; > +- private final String monitorAddr; > +- private final List events =3D new ArrayList<>(); > ++ private final Ctx ctx; > ++ private final String monitorAddr; > ++ private final ZMQ.Event[] events =3D new ZMQ.Event[1]; > + > + public SocketMonitor(Ctx ctx, String monitorAddr) > + { > +@@ -41,15 +44,15 @@ public void run() > + boolean rc =3D s.connect(monitorAddr); > + assertThat(rc, is(true)); > + // Only some of the exceptional events could fire > +- while (true) { > +- ZMQ.Event event =3D ZMQ.Event.read(s); > +- if (event =3D=3D null && s.errno() =3D=3D ZError.ETERM)= { > +- break; > +- } > +- assertThat(event, notNullValue()); > +- > +- events.add(event); > ++ > ++ ZMQ.Event event =3D ZMQ.Event.read(s); > ++ if (event =3D=3D null && s.errno() =3D=3D ZError.ETERM) { > ++ s.close(); > ++ return; > + } > ++ assertThat(event, notNullValue()); > ++ > ++ events[0] =3D event; > + s.close(); > + } > + } > +@@ -69,11 +72,12 @@ public void run() > + boolean rc =3D ZMQ.setSocketOption(receiver, ZMQ.ZMQ_LINGER, 0)= ; > + assertThat(rc, is(true)); > + > +- SocketMonitor monitor =3D new SocketMonitor(ctx, > "inproc://monitor"); > +- monitor.start(); > + rc =3D ZMQ.monitorSocket(receiver, "inproc://monitor", > ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL); > + assertThat(rc, is(true)); > + > ++ SocketMonitor monitor =3D new SocketMonitor(ctx, > "inproc://monitor"); > ++ monitor.start(); > ++ > + rc =3D ZMQ.bind(receiver, host); > + assertThat(rc, is(true)); > + > +@@ -81,17 +85,18 @@ public void run() > + OutputStream out =3D sender.getOutputStream(); > + for (ByteBuffer raw : raws) { > + out.write(raw.array()); > +- ZMQ.msleep(100); > + } > + > + Msg msg =3D ZMQ.recv(receiver, 0); > + assertThat(msg, notNullValue()); > + assertThat(new String(msg.data(), ZMQ.CHARSET), is(payload)); > + > +- ZMQ.msleep(500); > +- assertThat(monitor.events.size(), is(1)); > +- assertThat(monitor.events.get(0).event, > is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL)); > +- assertThat((Integer) monitor.events.get(0).arg, is(version)); > ++ monitor.join(); > ++ > ++ final Event event =3D monitor.events[0]; > ++ assertThat(event, notNullValue()); > ++ assertThat(event.event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL)); > ++ assertThat((Integer) event.arg, is(version)); > + > + InputStream in =3D sender.getInputStream(); > + byte[] data =3D new byte[255]; > +diff --git a/src/test/java/zmq/io/V0ProtocolTest.java > b/src/test/java/zmq/io/V0ProtocolTest.java > +index bd547d23..1a5b7aef 100644 > +--- a/src/test/java/zmq/io/V0ProtocolTest.java > ++++ b/src/test/java/zmq/io/V0ProtocolTest.java > +@@ -10,6 +10,18 @@ > + > + public class V0ProtocolTest extends AbstractProtocolVersion > + { > ++ @Test > ++ public void testFixIssue524() throws IOException, > InterruptedException > ++ { > ++ for (int idx =3D 0; idx < REPETITIONS; ++idx) { > ++ if (idx % 100 =3D=3D 0) { > ++ System.out.print(idx + " "); > ++ } > ++ testProtocolVersion0short(); > ++ } > ++ System.out.println(); > ++ } > ++ > + @Test(timeout =3D 2000) > + public void testProtocolVersion0short() throws IOException, > InterruptedException > + { > +diff --git a/src/test/java/zmq/io/V1ProtocolTest.java > b/src/test/java/zmq/io/V1ProtocolTest.java > +index e1045f34..764159d0 100644 > +--- a/src/test/java/zmq/io/V1ProtocolTest.java > ++++ b/src/test/java/zmq/io/V1ProtocolTest.java > +@@ -10,7 +10,19 @@ > + > + public class V1ProtocolTest extends AbstractProtocolVersion > + { > +- @Test(timeout =3D 2000) > ++ @Test > ++ public void testFixIssue524() throws IOException, > InterruptedException > ++ { > ++ for (int idx =3D 0; idx < REPETITIONS; ++idx) { > ++ if (idx % 100 =3D=3D 0) { > ++ System.out.print(idx + " "); > ++ } > ++ testProtocolVersion1short(); > ++ } > ++ System.out.println(); > ++ } > ++ > ++ @Test > + public void testProtocolVersion1short() throws IOException, > InterruptedException > + { > + List raws =3D raws(0); > +@@ -25,7 +37,7 @@ public void testProtocolVersion1short() throws > IOException, InterruptedException > + assertProtocolVersion(1, raws, "abcdefg"); > + } > + > +- @Test(timeout =3D 2000) > ++ @Test > + public void testProtocolVersion1long() throws IOException, > InterruptedException > + { > + List raws =3D raws(0); > +diff --git a/src/test/java/zmq/io/V2ProtocolTest.java > b/src/test/java/zmq/io/V2ProtocolTest.java > +index d5e64bce..7fda31bc 100644 > +--- a/src/test/java/zmq/io/V2ProtocolTest.java > ++++ b/src/test/java/zmq/io/V2ProtocolTest.java > +@@ -21,7 +21,19 @@ protected ByteBuffer identity() > + .put((byte) 0); > + } > + > +- @Test(timeout =3D 2000) > ++ @Test > ++ public void testFixIssue524() throws IOException, > InterruptedException > ++ { > ++ for (int idx =3D 0; idx < REPETITIONS; ++idx) { > ++ if (idx % 100 =3D=3D 0) { > ++ System.out.print(idx + " "); > ++ } > ++ testProtocolVersion2short(); > ++ } > ++ System.out.println(); > ++ } > ++ > ++ @Test > + public void testProtocolVersion2short() throws IOException, > InterruptedException > + { > + List raws =3D raws(1); > +@@ -38,7 +50,7 @@ public void testProtocolVersion2short() throws > IOException, InterruptedException > + assertProtocolVersion(2, raws, "abcdefg"); > + } > + > +- @Test(timeout =3D 2000) > ++ @Test > + public void testProtocolVersion2long() throws IOException, > InterruptedException > + { > + List raws =3D raws(1); > -- > 2.16.2 > > Sorry, sent the wrong patch. --001a11446d98e0908a0567525953 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


2018-03-13 22:54 GMT+01:00 G=C3=A1bor Boskovits <<= a href=3D"mailto:boskovits@gmail.com" target=3D"_blank">boskovits@gmail.com= >:
* gnu/packages/patches/j= ava-jeromq-fix-tests.patch: New file.
* gnu/loca= l.mk (dist_patch_DATA): Add it.
* gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
[arguments](#test-exclude): Disable more failing tests.
---
=C2=A0gnu/= local.mk=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2= =A0 =C2=A01 +
=C2=A0gnu/packages/java.scm=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 11 +-
=C2=A0gnu/packages/patches/java-jeromq-fix-tests.patch | 253 +++++++++= ++++++++++++++
=C2=A03 files changed, 263 insertions(+), 2 deletions(-)
=C2=A0create mode 100644 gnu/packages/patches/java-jeromq-fix-tests.pa= tch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9684d949f..2bae3660c 100644
--- a/gnu/= local.mk
+++ b/gnu/= local.mk
@@ -782,6 +782,7 @@ dist_patch_DATA =3D=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
=C2=A0 =C2=A0%D%/packages/patches/intltool-perl-compatibility.pat= ch=C2=A0 =C2=A0 =C2=A0 =C2=A0\
=C2=A0 =C2=A0%D%/packages/patches/isl-0.11.1-aarch64-support.patch=C2= =A0 =C2=A0 =C2=A0 =C2=A0 \
=C2=A0 =C2=A0%D%/packages/patches/jacal-fix-texinfo.patch=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
+=C2=A0 %D%/packages/patches/java-jeromq-fix-tests.patch=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
=C2=A0 =C2=A0%D%/packages/patches/java-powermock-fix-java-files.patch= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
=C2=A0 =C2=A0%D%/packages/patches/java-xerces-bootclasspath.patch \ =C2=A0 =C2=A0%D%/packages/patches/java-xerces-build_dont_unzip.patch= =C2=A0 =C2=A0 =C2=A0 \
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 0f8c04e8b..85a8c9b3a 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -8117,7 +8117,8 @@ protocol-independent framework to build mail and mess= aging applications.")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(file-name (string-a= ppend name "-" version "-checkout"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(sha256
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (base32
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "1gxkp7lv2ahy= mgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "1gxkp7lv2ahy= mgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (patches (search-patches = "java-jeromq-fix-tests.patch"))))
=C2=A0 =C2=A0 =C2=A0(build-system ant-build-system)
=C2=A0 =C2=A0 =C2=A0(arguments
=C2=A0 =C2=A0 =C2=A0 `(#:jar-name "java-jeromq.jar"
@@ -8131,7 +8132,13 @@ protocol-independent framework to build mail and mes= saging applications.")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Failures
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "**/DealerSpecTest.java"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "**/CustomDecoderTest.java" -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/CustomEncoderTest.java"))<= wbr>)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/CustomEncoderTest.java" +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/ConnectRidTest.java"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/ReqSpecTest.java"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/PushPullSpecTest.java"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/PubSubHwmTest.java"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/RouterSpecTest.java"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"**/ProxyTest.java")))
=C2=A0 =C2=A0 =C2=A0(inputs
=C2=A0 =C2=A0 =C2=A0 `(("java-jnacl" ,java-jnacl)))
=C2=A0 =C2=A0 =C2=A0(native-inputs
diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch b/gnu/pa= ckages/patches/java-jeromq-fix-tests.patch
new file mode 100644
index 000000000..5466b9270
--- /dev/null
+++ b/gnu/packages/patches/java-jeromq-fix-tests.patch
@@ -0,0 +1,253 @@
+From 5803aadd3f209eba1ffbb2cf7bf16778019dbee1 Mon Sep 17 00:00:00 200= 1
+From: fredoboulo <fredoboulo@users.noreply.github.com>
+Date: Fri, 23 Feb 2018 23:55:57 +0100
+Subject: [PATCH] Fix #524 : V1 and V2 protocol downgrades handle received = data
+ in handshake buffer
+
+This patch is upstream pull request, see:
+https://gihub.com/zeromq/jeromq/pull/527.
+
+It is merged on commit c2afa9c, and we can drop it on the
+0.4.4 release.
+
+---
+ src/main/java/zmq/io/StreamEngine.java=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 | 21 ++++++++++--
+ src/test/java/zmq/io/AbstractProtocolVersion.java | 41 +++++++++++++= ----------
+ src/test/java/zmq/io/V0ProtocolTest.java=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | 12 +++++++
+ src/test/java/zmq/io/V1ProtocolTest.java=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | 16 +++++++--
+ src/test/java/zmq/io/V2ProtocolTest.java=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | 16 +++++++--
+ 5 files changed, 81 insertions(+), 25 deletions(-)
+
+diff --git a/src/main/java/zmq/io/StreamEngine.java b/src/main/java/z= mq/io/StreamEngine.java
+index b8933c92..fe2f2d8d 100644
+--- a/src/main/java/zmq/io/StreamEngine.java
++++ b/src/main/java/zmq/io/StreamEngine.java
+@@ -816,9 +816,7 @@ private boolean handshake()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assert (bufferSize =3D=3D = headerSize);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//=C2=A0 Make sure the dec= oder sees the data we have already received.
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 greetingRecv.flip();
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 inpos =3D greetingRecv;
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 insize =3D greetingRecv.limit()= ;
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 decodeDataAfterHandshake(0); +
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//=C2=A0 To allow for inte= roperability with peers that do not forward
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//=C2=A0 their subscriptio= ns, we inject a phantom subscription message
+@@ -846,6 +844,8 @@ else if (greetingRecv.get(revisionPos) =3D=3D Protocol= .V1.revision) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0encoder =3D new V1Encoder(= errno, Config.OUT_BATCH_SIZE.getValue());
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0decoder =3D new V1Decoder(= errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.al= locator);
++
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 decodeDataAfterHandshake(V2_GR<= wbr>EETING_SIZE);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else if (greetingRecv.get(revisionPos) = =3D=3D Protocol.V2.revision) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//=C2=A0 ZMTP/2.0 framing.=
+@@ -859,6 +859,8 @@ else if (greetingRecv.get(revisionPos) =3D=3D Protocol= .V2.revision) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0encoder =3D new V2Encoder(= errno, Config.OUT_BATCH_SIZE.getValue());
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0decoder =3D new V2Decoder(= errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.al= locator);
++
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 decodeDataAfterHandshake(V2_GR<= wbr>EETING_SIZE);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0zmtpVersion =3D Protocol.V= 3;
+@@ -904,6 +906,19 @@ else if (greetingRecv.get(revisionPos) =3D=3D Protoco= l.V2.revision) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return true;
+=C2=A0 =C2=A0 =C2=A0}
+
++=C2=A0 =C2=A0 private void decodeDataAfterHandshake(int greetingSize)
++=C2=A0 =C2=A0 {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 final int pos =3D greetingRecv.position(); ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (pos > greetingSize) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // data is present after handsh= ake
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 greetingRecv.position(greeting<= wbr>Size).limit(pos);
++
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 //=C2=A0 Make sure the decoder = sees this extra data.
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 inpos =3D greetingRecv;
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 insize =3D greetingRecv.remaini= ng();
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
++=C2=A0 =C2=A0 }
++
+=C2=A0 =C2=A0 =C2=A0private Msg identityMsg()
+=C2=A0 =C2=A0 =C2=A0{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Msg msg =3D new Msg(options.identitySize= );
+diff --git a/src/test/java/zmq/io/AbstractProtocolVersion.java b/src/= test/java/zmq/io/AbstractProtocolVersion.java
+index e60db403..aa06b4a7 100644
+--- a/src/test/java/zmq/io/AbstractProtocolVersion.java
++++ b/src/test/java/zmq/io/AbstractProtocolVersion.java
+@@ -18,15 +18,18 @@
+ import zmq.SocketBase;
+ import zmq.ZError;
+ import zmq.ZMQ;
++import zmq.ZMQ.Event;
+ import zmq.util.Utils;
+
+ public abstract class AbstractProtocolVersion
+ {
++=C2=A0 =C2=A0 protected static final int REPETITIONS =3D 1000;
++
+=C2=A0 =C2=A0 =C2=A0static class SocketMonitor extends Thread
+=C2=A0 =C2=A0 =C2=A0{
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 private final Ctx=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0ctx;
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 private final String=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 monitorAddr;
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 private final List<ZMQ.Event> events = =3D new ArrayList<>();
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 private final Ctx=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0ctx;
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 private final String=C2=A0 =C2=A0 =C2=A0 moni= torAddr;
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 private final ZMQ.Event[] events =3D new ZMQ.= Event[1];
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0public SocketMonitor(Ctx ctx, String mon= itorAddr)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{
+@@ -41,15 +44,15 @@ public void run()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0boolean rc =3D s.connect(m= onitorAddr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertThat(rc, is(true));<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// Only some of the except= ional events could fire
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 while (true) {
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ZMQ.Event event = =3D ZMQ.Event.read(s);
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (event =3D=3D = null && s.errno() =3D=3D ZError.ETERM) {
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bre= ak;
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat(event,= notNullValue());
+-
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 events.add(event)= ;
++
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ZMQ.Event event =3D ZMQ.Event.r= ead(s);
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (event =3D=3D null &&= ; s.errno() =3D=3D ZError.ETERM) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s.close();
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat(event, notNullValue(= ));
++
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 events[0] =3D event;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s.close();
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0}
+@@ -69,11 +72,12 @@ public void run()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0boolean rc =3D ZMQ.setSocketOption(recei= ver, ZMQ.ZMQ_LINGER, 0);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertThat(rc, is(true));
+
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 SocketMonitor monitor =3D new SocketMonitor(c= tx, "inproc://monitor");
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor.start();
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rc =3D ZMQ.monitorSocket(receiver, "= ;inproc://monitor", ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertThat(rc, is(true));
+
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 SocketMonitor monitor =3D new SocketMonitor(c= tx, "inproc://monitor");
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor.start();
++
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rc =3D ZMQ.bind(receiver, host);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertThat(rc, is(true));
+
+@@ -81,17 +85,18 @@ public void run()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0OutputStream out =3D sender.getOutputStr= eam();
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (ByteBuffer raw : raws) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0out.write(raw.array()); +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ZMQ.msleep(100);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Msg msg =3D ZMQ.recv(receiver, 0);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertThat(msg, notNullValue());
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertThat(new String(msg.data(), ZMQ.CH= ARSET), is(payload));
+
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 ZMQ.msleep(500);
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat(monitor.events.size(), is(1))= ;
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat(monitor.events.get(0).event, = is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
+-=C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat((Integer) monitor.events.get(0).ar= g, is(version));
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 monitor.join();
++
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 final Event event =3D monitor.events[0];
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat(event, notNullValue());
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat(event.event, is(ZMQ.ZMQ_EVENT_HAND= SHAKE_PROTOCOL));
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assertThat((Integer) event.arg, is(version));=
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0InputStream in =3D sender.getInputStream= ();
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0byte[] data =3D new byte[255];
+diff --git a/src/test/java/zmq/io/V0ProtocolTest.java b/src/test/java= /zmq/io/V0ProtocolTest.java
+index bd547d23..1a5b7aef 100644
+--- a/src/test/java/zmq/io/V0ProtocolTest.java
++++ b/src/test/java/zmq/io/V0ProtocolTest.java
+@@ -10,6 +10,18 @@
+
+ public class V0ProtocolTest extends AbstractProtocolVersion
+ {
++=C2=A0 =C2=A0 @Test
++=C2=A0 =C2=A0 public void testFixIssue524() throws IOException, Interrupt= edException
++=C2=A0 =C2=A0 {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (int idx =3D 0; idx < REPETITIONS; ++i= dx) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (idx % 100 =3D=3D 0) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.print(= idx + " ");
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 testProtocolVersion0short(); ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.println();
++=C2=A0 =C2=A0 }
++
+=C2=A0 =C2=A0 =C2=A0@Test(timeout =3D 2000)
+=C2=A0 =C2=A0 =C2=A0public void testProtocolVersion0short() throws IOExcep= tion, InterruptedException
+=C2=A0 =C2=A0 =C2=A0{
+diff --git a/src/test/java/zmq/io/V1ProtocolTest.java b/src/test/java= /zmq/io/V1ProtocolTest.java
+index e1045f34..764159d0 100644
+--- a/src/test/java/zmq/io/V1ProtocolTest.java
++++ b/src/test/java/zmq/io/V1ProtocolTest.java
+@@ -10,7 +10,19 @@
+
+ public class V1ProtocolTest extends AbstractProtocolVersion
+ {
+-=C2=A0 =C2=A0 @Test(timeout =3D 2000)
++=C2=A0 =C2=A0 @Test
++=C2=A0 =C2=A0 public void testFixIssue524() throws IOException, Interrupt= edException
++=C2=A0 =C2=A0 {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (int idx =3D 0; idx < REPETITIONS; ++i= dx) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (idx % 100 =3D=3D 0) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.print(= idx + " ");
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 testProtocolVersion1short(); ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.println();
++=C2=A0 =C2=A0 }
++
++=C2=A0 =C2=A0 @Test
+=C2=A0 =C2=A0 =C2=A0public void testProtocolVersion1short() throws IOExcep= tion, InterruptedException
+=C2=A0 =C2=A0 =C2=A0{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0List<ByteBuffer> raws =3D raws(0);=
+@@ -25,7 +37,7 @@ public void testProtocolVersion1short() throws IOExcepti= on, InterruptedException
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertProtocolVersion(1, raws, "abc= defg");
+=C2=A0 =C2=A0 =C2=A0}
+
+-=C2=A0 =C2=A0 @Test(timeout =3D 2000)
++=C2=A0 =C2=A0 @Test
+=C2=A0 =C2=A0 =C2=A0public void testProtocolVersion1long() throws IOExcept= ion, InterruptedException
+=C2=A0 =C2=A0 =C2=A0{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0List<ByteBuffer> raws =3D raws(0);=
+diff --git a/src/test/java/zmq/io/V2ProtocolTest.java b/src/test/java= /zmq/io/V2ProtocolTest.java
+index d5e64bce..7fda31bc 100644
+--- a/src/test/java/zmq/io/V2ProtocolTest.java
++++ b/src/test/java/zmq/io/V2ProtocolTest.java
+@@ -21,7 +21,19 @@ protected ByteBuffer identity()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.put((byte) = 0);
+=C2=A0 =C2=A0 =C2=A0}
+
+-=C2=A0 =C2=A0 @Test(timeout =3D 2000)
++=C2=A0 =C2=A0 @Test
++=C2=A0 =C2=A0 public void testFixIssue524() throws IOException, Interrupt= edException
++=C2=A0 =C2=A0 {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (int idx =3D 0; idx < REPETITIONS; ++i= dx) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (idx % 100 =3D=3D 0) {
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.print(= idx + " ");
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 testProtocolVersion2short(); ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
++=C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.println();
++=C2=A0 =C2=A0 }
++
++=C2=A0 =C2=A0 @Test
+=C2=A0 =C2=A0 =C2=A0public void testProtocolVersion2short() throws IOExcep= tion, InterruptedException
+=C2=A0 =C2=A0 =C2=A0{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0List<ByteBuffer> raws =3D raws(1);=
+@@ -38,7 +50,7 @@ public void testProtocolVersion2short() throws IOExcepti= on, InterruptedException
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assertProtocolVersion(2, raws, "abc= defg");
+=C2=A0 =C2=A0 =C2=A0}
+
+-=C2=A0 =C2=A0 @Test(timeout =3D 2000)
++=C2=A0 =C2=A0 @Test
+=C2=A0 =C2=A0 =C2=A0public void testProtocolVersion2long() throws IOExcept= ion, InterruptedException
+=C2=A0 =C2=A0 =C2=A0{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0List<ByteBuffer> raws =3D raws(1);=
--
2.16.2

Sorry, sent the wrong patch.
--001a11446d98e0908a0567525953--