Skip to content

Commit

Permalink
[BUGFIX] with the system under load the NioSender stop could cause an…
Browse files Browse the repository at this point in the history
…y threads using the sender to lock up.
  • Loading branch information
Jim Carroll committed May 16, 2017
1 parent f96f67a commit d9ee069
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -57,9 +58,12 @@ public final class NioSender implements Sender {
public void send(final Object message) throws MessageTransportException {
boolean done = false;
while (running && !done) {
if (running)
dontInterrupt(() -> messages.put(message));
done = true;
if (running) {
try {
// let's not try forever in case we're locked up and shutting down.
done = messages.offer(message, 1, TimeUnit.SECONDS);
} catch (final InterruptedException ie) {}
}
}
}

Expand Down

0 comments on commit d9ee069

Please sign in to comment.