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

View File

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