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:14 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk f5b98b8fa -> bce3415b1


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


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

Branch: refs/heads/trunk
Commit: bce3415b18fd0d2b7ab05330f2590f98939b8850
Parents: f5b98b8
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:08 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/bce3415b/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