Skip to content

Commit 686f33c

Browse files
authored
Merge pull request #221 from andrewang-canva/andrewang/buffer-clear-v2.X
clear buffers before returning to pool in v2.X
2 parents 740e5ce + 63fb837 commit 686f33c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/main/java/com/timgroup/statsd/StatsDSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void sendLoop() {
8181
try {
8282

8383
if (buffer != null) {
84+
buffer.clear();
8485
pool.put(buffer);
8586
}
8687

@@ -94,7 +95,6 @@ void sendLoop() {
9495
buffer.flip();
9596
final int sentBytes = clientChannel.send(buffer, address);
9697

97-
buffer.clear();
9898
if (sizeOfBuffer != sentBytes) {
9999
throw new IOException(
100100
String.format("Could not send stat %s entirely to %s. Only sent %d out of %d bytes",

src/test/java/com/timgroup/statsd/NonBlockingStatsDClientTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,4 +1337,5 @@ public SlowStatsDNonBlockingStatsDClient build() throws StatsDClientException {
13371337
}
13381338
}
13391339
}
1340+
13401341
}

0 commit comments

Comments
 (0)