This commit is contained in:
Shikhar Bhushan
2010-08-06 00:01:51 +01:00
parent 486dbf2b05
commit 3cd446b462
2 changed files with 6 additions and 8 deletions

View File

@@ -77,7 +77,7 @@ final class Heartbeater
public void run() {
log.debug("Starting");
try {
while (!Thread.currentThread().isInterrupted()) {
while (!isInterrupted()) {
final int hi = getPositiveInterval();
if (trans.isRunning()) {
log.info("Sending heartbeat since {} seconds elapsed", hi);
@@ -86,7 +86,7 @@ final class Heartbeater
Thread.sleep(hi * 1000);
}
} catch (Exception e) {
if (Thread.currentThread().isInterrupted()) {
if (isInterrupted()) {
// We are meant to shut up and draw to a close if interrupted
} else
trans.die(e);

View File

@@ -41,22 +41,20 @@ import org.slf4j.LoggerFactory;
import java.io.InputStream;
final class Reader
public final class Reader
extends Thread {
private final Logger log = LoggerFactory.getLogger(getClass());
private final TransportImpl trans;
Reader(TransportImpl trans) {
public Reader(TransportImpl trans) {
this.trans = trans;
setName("reader");
}
@Override
public void run() {
final Thread curThread = Thread.currentThread();
try {
final Decoder decoder = trans.getDecoder();
@@ -66,7 +64,7 @@ final class Reader
int needed = 1;
while (!curThread.isInterrupted()) {
while (!isInterrupted()) {
int read = inp.read(recvbuf, 0, needed);
if (read == -1)
throw new TransportException("Broken transport; encountered EOF");
@@ -75,7 +73,7 @@ final class Reader
}
} catch (Exception e) {
if (curThread.isInterrupted()) {
if (isInterrupted()) {
// We are meant to shut up and draw to a close if interrupted
} else
trans.die(e);