Skip to content

Commit

Permalink
KAFKA-3662; Fix timing issue in SocketServerTest.tooBigRequestIsRejected
Browse files Browse the repository at this point in the history
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 <[email protected]>

Reviewers: Ismael Juma <[email protected]>

Closes apache#1349 from rajinisivaram/KAFKA-3662
  • Loading branch information
rajinisivaram authored and ijuma committed May 9, 2016
1 parent f5b98b8 commit bce3415
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bce3415

Please sign in to comment.