kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-3662; Fix timing issue in SocketServerTest.tooBigRequestIsRejected
Date Mon, 09 May 2016 13:48:24 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.10.0 7a0b9eb06 -> 9f583d96f


KAFKA-3662; Fix timing issue in SocketServerTest.tooBigRequestIsRejected

Test sends large request using multiple writes of length followed by request body. The first
write should succeed, but since the server closes the connection on processing the length
that is too big, subsequent writes may fail. Modified test to handle this exception.

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #1349 from rajinisivaram/KAFKA-3662

(cherry picked from commit bce3415b18fd0d2b7ab05330f2590f98939b8850)
Signed-off-by: Ismael Juma <ismael@juma.me.uk>


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/9f583d96
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/9f583d96
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/9f583d96

Branch: refs/heads/0.10.0
Commit: 9f583d96f68578fa6fa395805b0e1057b58d1ac7
Parents: 7a0b9eb
Author: Rajini Sivaram <rajinisivaram@googlemail.com>
Authored: Mon May 9 14:48:08 2016 +0100
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Mon May 9 14:48:19 2016 +0100

----------------------------------------------------------------------
 core/src/test/scala/unit/kafka/network/SocketServerTest.scala | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/9f583d96/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/network/SocketServerTest.scala b/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
index 81e5232..d215430 100644
--- a/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
+++ b/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
@@ -150,8 +150,13 @@ class SocketServerTest extends JUnitSuite {
     val tooManyBytes = new Array[Byte](server.config.socketRequestMaxBytes + 1)
     new Random().nextBytes(tooManyBytes)
     val socket = connect()
-    sendRequest(socket, tooManyBytes, Some(0))
+    val outgoing = new DataOutputStream(socket.getOutputStream)
+    outgoing.writeInt(tooManyBytes.length)
     try {
+      // Server closes client connection when it processes the request length because
+      // it is too big. The write of request body may fail if the connection has been closed.
+      outgoing.write(tooManyBytes)
+      outgoing.flush()
       receiveResponse(socket)
     } catch {
       case e: IOException => // thats fine


Mime
View raw message