mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
PeerGroup: log exceptions in executor jobs, as the executor doesn't do this itself (gah)
This commit is contained in:
@@ -413,6 +413,14 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
go();
|
||||
} catch (Throwable e) {
|
||||
log.error("Exception when trying to build connections", e); // The executor swallows exceptions :(
|
||||
}
|
||||
}
|
||||
|
||||
public void go() {
|
||||
if (!vRunning) return;
|
||||
|
||||
boolean doDiscovery = false;
|
||||
@@ -825,6 +833,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
return executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
log.info("Starting ...");
|
||||
if (torClient != null) {
|
||||
log.info("Starting Tor/Orchid ...");
|
||||
@@ -840,6 +849,9 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
channels.awaitRunning();
|
||||
triggerConnections();
|
||||
setupPinging();
|
||||
} catch (Throwable e) {
|
||||
log.error("Exception when starting up", e); // The executor swallows exceptions :(
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -861,6 +873,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
ListenableFuture future = executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
log.info("Stopping ...");
|
||||
// Blocking close of all sockets.
|
||||
channels.stopAsync();
|
||||
@@ -872,6 +885,9 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
torClient.stop();
|
||||
}
|
||||
vRunning = false;
|
||||
} catch (Throwable e) {
|
||||
log.error("Exception when shutting down", e); // The executor swallows exceptions :(
|
||||
}
|
||||
}
|
||||
});
|
||||
executor.shutdown();
|
||||
@@ -1017,6 +1033,14 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
go();
|
||||
} catch (Throwable e) {
|
||||
log.error("Exception when trying to recalculate Bloom filter", e); // The executor swallows exceptions :(
|
||||
}
|
||||
}
|
||||
|
||||
public void go() {
|
||||
checkState(!lock.isHeldByCurrentThread());
|
||||
// Fully verifying mode doesn't use this optimization (it can't as it needs to see all transactions).
|
||||
if (chain != null && chain.shouldVerifyTransactions())
|
||||
@@ -1273,6 +1297,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
vPingTask = executor.scheduleAtFixedRate(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (getPingIntervalMsec() <= 0) {
|
||||
ListenableScheduledFuture<?> task = vPingTask;
|
||||
if (task != null) {
|
||||
@@ -1286,6 +1311,9 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
continue;
|
||||
peer.ping();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Exception in ping loop", e); // The executor swallows exceptions :(
|
||||
}
|
||||
}
|
||||
}, getPingIntervalMsec(), getPingIntervalMsec(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
Reference in New Issue
Block a user