From commits-return-7898-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Fri Aug 2 11:56:41 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5A180180647 for ; Fri, 2 Aug 2019 13:56:41 +0200 (CEST) Received: (qmail 25334 invoked by uid 500); 2 Aug 2019 11:56:40 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 25316 invoked by uid 99); 2 Aug 2019 11:56:40 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Aug 2019 11:56:40 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 0C5DD816C5; Fri, 2 Aug 2019 11:56:37 +0000 (UTC) Date: Fri, 02 Aug 2019 11:56:36 +0000 To: "commits@zookeeper.apache.org" Subject: [zookeeper] branch branch-3.5 updated: ZOOKEEPER-3455: fix UnifiedServerSocketTest on jdk 13 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <156474699692.13030.12137038745966892997@gitbox.apache.org> From: andor@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: zookeeper X-Git-Refname: refs/heads/branch-3.5 X-Git-Reftype: branch X-Git-Oldrev: e27eab65c546a991a226dac2684a64df6a17770c X-Git-Newrev: f2cb75d19514e898e39f70797fcb45feb051c07e X-Git-Rev: f2cb75d19514e898e39f70797fcb45feb051c07e X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. andor pushed a commit to branch branch-3.5 in repository https://gitbox.apache.org/repos/asf/zookeeper.git The following commit(s) were added to refs/heads/branch-3.5 by this push: new f2cb75d ZOOKEEPER-3455: fix UnifiedServerSocketTest on jdk 13 f2cb75d is described below commit f2cb75d19514e898e39f70797fcb45feb051c07e Author: Mate Szalay-Beko AuthorDate: Fri Aug 2 13:55:01 2019 +0200 ZOOKEEPER-3455: fix UnifiedServerSocketTest on jdk 13 The `UnifiedServerSocketTest.testConnectWithoutSSLToStrictServer` fails on OpenJDK 13 because in the new default socket implementation (https://openjdk.java.net/jeps/353) the `NioSocketImpl.getInputStream.read()` behaves differently than the old `SocketInputStream.read()`. A workaround could be to execute the tests using the `-Djdk.net.usePlainSocketImpl` system property (hardcoding it in the maven / ant configs), which enforces the usage of the old socket implementation in JDK 13. But I preferred instead to make the test compatible with both older and newer JDK, so it should succeed even if someone is executing it outside of our build environment. Author: Mate Szalay-Beko Reviewers: andor@apache.org Closes #1029 from symat/master (cherry picked from commit 6b6ff1d11009d1301eb48d7801175d6af7dbf3fe) Signed-off-by: Andor Molnar --- .../server/quorum/UnifiedServerSocketTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/UnifiedServerSocketTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/UnifiedServerSocketTest.java index ddc05dc..b74fcda 100644 --- a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/UnifiedServerSocketTest.java +++ b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/UnifiedServerSocketTest.java @@ -212,6 +212,10 @@ public class UnifiedServerSocketTest extends BaseX509ParameterizedTestCase { synchronized byte[] getDataFromClient(int index) { return dataFromClients.get(index); } + + synchronized boolean receivedAnyDataFromClient() { + return !dataFromClients.isEmpty(); + } } private SSLSocket connectWithSSL() throws IOException, X509Exception, InterruptedException { @@ -405,13 +409,23 @@ public class UnifiedServerSocketTest extends BaseX509ParameterizedTestCase { socket.getOutputStream().flush(); byte[] buf = new byte[DATA_TO_CLIENT.length]; try { - socket.getInputStream().read(buf, 0, buf.length); + int bytesRead = socket.getInputStream().read(buf, 0, buf.length); + if(bytesRead == -1) { + // Using the NioSocketImpl after JDK 13, the expected behaviour on the client side + // is to reach the end of the stream (bytesRead == -1), without a socket exception. + return; + } } catch (SocketException e) { - // We expect the other end to hang up the connection + // Using the old PlainSocketImpl (prior to JDK 13) we expect to get Socket Exception return; } finally { forceClose(socket); serverThread.shutdown(TIMEOUT); + + // independently of the client socket implementation details, we always make sure the + // server didn't receive any data during the test + Assert.assertFalse("The strict server accepted connection without SSL.", + serverThread.receivedAnyDataFromClient()); } Assert.fail("Expected server to hang up the connection. Read from server succeeded unexpectedly."); }