Skip to content

Commit 5cdf70a

Browse files
committed
Fix UnixSocketTest#resist_dsd_restart
Avoid sending too many metrics to a closed socket, to avoid a race condition with the lastException reset. Occasionally, two metrics will be sent to the client after the server socket was removed. First one triggers an exception and causes the send loop to break. Test case then resets the lastException variable, while the client is still running and has another message buffered. If that is delivered before the server is started, it triggers another exception and causes nullValue() check to fail and the end of the test case.
1 parent e4fc80f commit 5cdf70a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ public void resist_dsd_restart() throws Exception {
129129
// Delete the socket file, client should throw an IOException
130130
lastException = new Exception();
131131
socketFile.delete();
132+
133+
client.gauge("mycount", 21);
132134
while(lastException.getMessage() == null) {
133-
client.gauge("mycount", 20);
134135
Thread.sleep(10);
135136
}
136137
assertThat(lastException.getMessage(), containsString("No such file or directory"));

0 commit comments

Comments
 (0)