Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve robustness of stream socket tests #240

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 4.4.3 / 2024.10.04

* [BUGFIX] Use correct buffer size for unix sockets. See [#256][]

## 4.4.2 / 2024.06.03

* [BUGFIX] Fix sampling and visibility issues with new direct client. See [#249][]
Expand Down Expand Up @@ -254,6 +258,7 @@ Fork from [indeedeng/java-dogstatsd-client] (https://github.com/indeedeng/java-d
[#243]: https://github.com/DataDog/java-dogstatsd-client/issues/243
[#247]: https://github.com/DataDog/java-dogstatsd-client/issues/247
[#249]: https://github.com/DataDog/java-dogstatsd-client/issues/249
[#256]: https://github.com/DataDog/java-dogstatsd-client/issues/256


[@PatrickAuld]: https://github.com/PatrickAuld
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The client jar is distributed via Maven central, and can be downloaded [from Mav
<dependency>
<groupId>com.datadoghq</groupId>
<artifactId>java-dogstatsd-client</artifactId>
<version>4.4.2</version>
<version>4.4.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>java-dogstatsd-client</artifactId>
<packaging>jar</packaging>
<name>java-dogstatsd-client</name>
<version>4.4.2</version>
<version>4.4.3</version>
<description>A tiny library allowing Java applications to communicate with DataDog statsd instances easily.</description>
<url>https://github.com/DataDog/java-dogstatsd-client</url>

Expand Down
12 changes: 7 additions & 5 deletions src/test/java/com/timgroup/statsd/UnixStreamSocketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public synchronized void handle(Exception exception) {
lastException = exception;
}

synchronized boolean lastExceptionMessageContains(String s) {
String msg = lastException.getMessage();
return msg != null && msg.contains(s);
}

@BeforeClass
public static void supportedOnly() throws IOException {
Assume.assumeTrue(TestHelpers.isUdsAvailable());
Expand Down Expand Up @@ -108,22 +113,19 @@ public void resist_dsd_restart() throws Exception {

// Close the server, client should throw an IOException
server.close();
while(lastException.getMessage() == null) {
while(!lastExceptionMessageContains("Connection refused")) {
client.gauge("mycount", 20);
Thread.sleep(10);
}
// Depending on the state of the client at that point we might get different messages.
assertThat(lastException.getMessage(), anyOf(containsString("Connection refused"), containsString("Broken pipe")));

// Delete the socket file, client should throw an IOException
lastException = new Exception();
socketFile.delete();

client.gauge("mycount", 21);
while(lastException.getMessage() == null) {
while(!lastExceptionMessageContains("No such file or directory")) {
Thread.sleep(10);
}
assertThat(lastException.getMessage(), containsString("No such file or directory"));

// Re-open the server, next send should work OK
DummyStatsDServer server2;
Expand Down