Fix NPE if some network interfaces become unavailable.
@@ -390,9 +390,11 @@ public class CollectLocalResourceUsage extends Thread {
}
NetIoCounter previous = entry.getValue();
NetIoCounter next = nextNetIoCounters.get(name);
+ if (next != null) {
deltaBytesSent += calcDeltaBytes(previous.bytesSent(), next.bytesSent());
deltaBytesRecv += calcDeltaBytes(previous.bytesRecv(), next.bytesRecv());
}
+ }
double upMbps = calcNetworkMbps(deltaBytesSent, deltaNanos);
double downMbps = calcNetworkMbps(deltaBytesRecv, deltaNanos);
return new AggregatedNetIoCounter(upMbps, downMbps);
