Skip to content

Commit f98c8eb

Browse files
committed
Guard forwarder thread from unhandled exceptions
Exceptions can arise due to bugs, such as invalid url or timeout value.
1 parent 72f2f59 commit f98c8eb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • dogstatsd-http-forwarder/src/main/java/com/datadoghq/dogstatsd/http/forwarder

dogstatsd-http-forwarder/src/main/java/com/datadoghq/dogstatsd/http/forwarder/Forwarder.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ public Forwarder(
7070
/** Runs the forwarding loop, delivering queued payloads until the thread is interrupted. */
7171
@Override
7272
public void run() {
73-
try {
74-
while (true) {
73+
while (true) {
74+
try {
7575
runOnce(queue.next());
76+
} catch (InterruptedException e) {
77+
return;
78+
} catch (Throwable t) {
79+
logger.log(Level.SEVERE, "unexpected error in forwarder loop", t);
7680
}
77-
} catch (InterruptedException e) {
78-
return;
7981
}
8082
}
8183

0 commit comments

Comments
 (0)