From bfcbb7e32fde1569d2d3225a5217eb36fb65812e Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 14 Sep 2016 23:36:19 +0200 Subject: [PATCH] Improve stability of ProgressLoggerTest in order to avoid : log_at_fixed_intervals(org.sonar.core.util.ProgressLoggerTest) java.util.ConcurrentModificationException: null at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) at java.util.ArrayList$Itr.next(ArrayList.java:851) at org.sonar.api.internal.google.common.collect.AbstractMapBasedMultimap$WrappedCollection$WrappedIterator.next(AbstractMapBasedMultimap.java:486) at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.sonar.core.util.ProgressLoggerTest.hasInfoLog(ProgressLoggerTest.java:71) at org.sonar.core.util.ProgressLoggerTest.log_at_fixed_intervals(ProgressLoggerTest.java:44) --- .../src/test/java/org/sonar/core/util/ProgressLoggerTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java index 57bb0de02d5..18eb5acd301 100644 --- a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java @@ -41,10 +41,11 @@ public class ProgressLoggerTest { ProgressLogger progress = new ProgressLogger("ProgressLoggerTest", counter, Loggers.get(getClass())); progress.setPeriodMs(1L); progress.start(); - while (!hasInfoLog("42 rows processed")) { + while (logTester.logs(LoggerLevel.INFO).size()<2) { Uninterruptibles.sleepUninterruptibly(1, TimeUnit.MILLISECONDS); } progress.stop(); + assertThat(hasInfoLog("42 rows processed")).isTrue(); // ability to manual log, generally final status counter.incrementAndGet(); -- 2.39.5