Skip to content

Commit 281c092

Browse files
committed
It was possible for the IsolatedMetric finalizer to cause an exception and this case was not properly caught.
This commit correctly logs the exception and returns an InvalidResult for that metric.
1 parent 32288a8 commit 281c092

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/main/java/nl/rug/jbi/jsm/core/execution/CalculationStageTask.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import nl.rug.jbi.jsm.core.event.EventBus;
1010
import org.apache.logging.log4j.LogManager;
1111
import org.apache.logging.log4j.Logger;
12+
import org.apache.logging.log4j.message.ParameterizedMessage;
1213

1314
import java.util.List;
1415
import java.util.Map;
@@ -69,11 +70,24 @@ public Class apply(final IsolatedMetric isolatedMetric) {
6970
for (final IsolatedMetric m : this.metricList) {
7071
final MetricState state = isolatedMetricData.get(m.getClass());
7172
if (state.isValid()) {
72-
results.add(m.getResult(this.dataStore.getIdentifier(), state));
73+
try {
74+
results.add(m.getResult(this.dataStore.getIdentifier(), state));
75+
continue;
76+
} catch (final Exception ex) {
77+
logger.warn(
78+
new ParameterizedMessage(
79+
"Exception occurred while finalizing '{}' for '{}'",
80+
m.getClass().getName(),
81+
state.getIdentifier()
82+
),
83+
ex
84+
);
85+
}
7386
} else {
7487
logger.warn("Failed to calculate '{}' for '{}'", m.getClass().getName(), state.getIdentifier());
75-
results.add(new InvalidResult(this.dataStore.getIdentifier(), m, "Error during calculation"));
7688
}
89+
90+
results.add(new InvalidResult(this.dataStore.getIdentifier(), m, "Error during calculation"));
7791
}
7892

7993
//Deliver Results

0 commit comments

Comments
 (0)