Fix a possible NPE situation caused by unregisterMetrics() if registerMetrics() fails to execute somehow (e.g. CLI input parameter problem such as cycle number < stride number)

This commit is contained in:
yabinmeng
2023-10-04 21:49:28 -05:00
parent 2213676cef
commit 47c87c64eb

View File

@@ -462,8 +462,10 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
this.threadsGauge = ActivityMetrics.register(new NBFunctionGauge(activity, () -> (double) this.motors.size(), "threads"));
}
private void unregisterMetrics() {
ActivityMetrics.unregister(this.threadsGauge);
this.threadsGauge=null;
if (this.threadsGauge != null) {
ActivityMetrics.unregister(this.threadsGauge);
this.threadsGauge = null;
}
}
private boolean shutdownExecutorService(int secondsToWait) {