Skip to content

Commit 619e4d9

Browse files
committed
Address test timing out
1 parent 11f408e commit 619e4d9

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,19 @@ public void resist_dsd_timeout() throws Exception {
178178
server.freeze();
179179

180180
Exception originalException = lastException;
181-
while (lastException == originalException) {
181+
int attempts = 0;
182+
while (lastException == originalException && attempts < 50) {
182183
client.gauge("mycount", 20);
184+
attempts++;
185+
Thread.sleep(100);
183186
}
187+
assertTrue(lastException != originalException);
184188
assertTrue(lastException instanceof IOException);
185189
String timeoutMessage = lastException.getMessage();
186-
assertThat(timeoutMessage, anyOf(containsString("timed out"), containsString("broken"), containsString("pipe")));
190+
// Message may be null for some exceptions (e.g. AsynchronousCloseException)
191+
if (timeoutMessage != null) {
192+
assertThat(timeoutMessage, anyOf(containsString("timed out"), containsString("broken"), containsString("pipe")));
193+
}
187194

188195
// Make sure we recover after we resume listening
189196
server.clear();

0 commit comments

Comments
 (0)