This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new ac35ef6 MINOR: Specify character encoding in NetworkTestUtils (#5965)
ac35ef6 is described below
commit ac35ef6242d6893223af946f3c9438b8b4294389
Author: Gardner Vickers <gardner@vickers.me>
AuthorDate: Sat Dec 8 12:36:14 2018 -0500
MINOR: Specify character encoding in NetworkTestUtils (#5965)
This attempts to address the flaky test `SaslAuthenticatorTest.testCannotReauthenticateWithDifferentPrincipal()`
I was not able to reproduce locally even after 150 test runs in a loop, but given the
error message:
```
org.junit.ComparisonFailure: expected:
<[6QBJiMZ6o5AqbNAjDTDjWtQSa4alfuUWsYKIy2tt7dz5heDaWZlz21yr8Gl4uEJkQABQXeEL0UebdpufDb5k8SvReSK6wYwQ9huP-9]>
but was:<[????����????OAUTHBEARER]>
```
`????����????` seems to mean invalid UTF-8.
We now specify the charset when writing out and reading in bytes.
Reviewers: Ismael Juma <ismael@juma.me.uk>
---
.../test/java/org/apache/kafka/common/network/NetworkTestUtils.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clients/src/test/java/org/apache/kafka/common/network/NetworkTestUtils.java b/clients/src/test/java/org/apache/kafka/common/network/NetworkTestUtils.java
index 578020e..2ca013b 100644
--- a/clients/src/test/java/org/apache/kafka/common/network/NetworkTestUtils.java
+++ b/clients/src/test/java/org/apache/kafka/common/network/NetworkTestUtils.java
@@ -18,6 +18,7 @@ package org.apache.kafka.common.network;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import static org.junit.Assert.assertEquals;
@@ -65,19 +66,18 @@ public class NetworkTestUtils {
}
public static void checkClientConnection(Selector selector, String node, int minMessageSize,
int messageCount) throws Exception {
-
waitForChannelReady(selector, node);
String prefix = TestUtils.randomString(minMessageSize);
int requests = 0;
int responses = 0;
- selector.send(new NetworkSend(node, ByteBuffer.wrap((prefix + "-0").getBytes())));
+ selector.send(new NetworkSend(node, ByteBuffer.wrap((prefix + "-0").getBytes(StandardCharsets.UTF_8))));
requests++;
while (responses < messageCount) {
selector.poll(0L);
assertEquals("No disconnects should have occurred.", 0, selector.disconnected().size());
for (NetworkReceive receive : selector.completedReceives()) {
- assertEquals(prefix + "-" + responses, new String(Utils.toArray(receive.payload())));
+ assertEquals(prefix + "-" + responses, new String(Utils.toArray(receive.payload()),
StandardCharsets.UTF_8));
responses++;
}
|