Github user mmiklavc commented on a diff in the pull request:
https://github.com/apache/metron/pull/1194#discussion_r217148606
--- Diff:
metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileBuilderBolt.java
---
@@ -372,15 +372,21 @@ protected void flushActive() {
* that their state is not lost.
*/
protected void flushExpired() {
+ List<ProfileMeasurement> measurements = null;
+ try {
+ // flush the expired profiles
+ synchronized (messageDistributor) {
+ measurements = messageDistributor.flushExpired();
+ emitMeasurements(measurements);
+ }
- // flush the expired profiles
- List<ProfileMeasurement> measurements;
- synchronized (messageDistributor) {
- measurements = messageDistributor.flushExpired();
- emitMeasurements(measurements);
+ } catch(Throwable t) {
+ // need to catch the exception, otherwise subsequent executions
would be suppressed.
+ // see
java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate
+ LOG.error("Failed to flush expired profiles", t);
}
- LOG.debug("Flushed expired profiles and found {} measurement(s).",
measurements.size());
+ LOG.debug("Flushed expired profiles and found {} measurement(s).",
CollectionUtils.size(measurements));
--- End diff --
Just a note - CollectionUtils.size() is null-safe. I'm assuming that's the
reason for the tweak in implementation here.
https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/CollectionUtils.html#size-java.lang.Object-
---