Skip to content

Commit

Permalink
[FLINK-10715] Suppress ConcurrnetModificationException in Slf4jReporter
Browse files Browse the repository at this point in the history
This commit suppress the ConcurrentModificationException thrown by the Slf4jReporter
report method. This exception occurs when a metric is added/removed while this report is reporting.
Suppressing this (somewhat expected exception) is needed by our e2e framework to reduce some
false-positive e2e test failures. This does not solves the root issue, which is being tracked in a different issue FLINK-10035.

This closes apache#7008.
  • Loading branch information
Igal Shilman authored and tillrohrmann committed Nov 2, 2018
1 parent d3696e5 commit e918488
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ConcurrentModificationException;
import java.util.Map;

/**
Expand Down Expand Up @@ -75,6 +76,16 @@ public void close() {

@Override
public void report() {
try {
tryReport();
}
catch (ConcurrentModificationException ignored) {
// at tryReport() we don't synchronize while iterating over the various maps which might cause a
// ConcurrentModificationException to be thrown, if concurrently a metric is being added or removed.
}
}

private void tryReport() {
// initialize with previous size to avoid repeated resizing of backing array
// pad the size to allow deviations in the final string, for example due to different double value representations
StringBuilder builder = new StringBuilder((int) (previousSize * 1.1));
Expand Down

0 comments on commit e918488

Please sign in to comment.