flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmetz...@apache.org
Subject flink git commit: [FLINK-2392][yarn tests] Address concurrent modification exception
Date Tue, 22 Sep 2015 16:26:19 GMT
Repository: flink
Updated Branches:
  refs/heads/master a3df109cf -> 47afdfbf9


[FLINK-2392][yarn tests] Address concurrent modification exception


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/47afdfbf
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/47afdfbf
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/47afdfbf

Branch: refs/heads/master
Commit: 47afdfbf917130c1288b67260f6c6236eea148e1
Parents: a3df109
Author: Robert Metzger <rmetzger@apache.org>
Authored: Tue Sep 22 12:40:50 2015 +0200
Committer: Robert Metzger <rmetzger@apache.org>
Committed: Tue Sep 22 15:19:47 2015 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/flink/yarn/UtilsTest.java | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/47afdfbf/flink-yarn-tests/src/main/java/org/apache/flink/yarn/UtilsTest.java
----------------------------------------------------------------------
diff --git a/flink-yarn-tests/src/main/java/org/apache/flink/yarn/UtilsTest.java b/flink-yarn-tests/src/main/java/org/apache/flink/yarn/UtilsTest.java
index 086384d..1e9e4fa 100644
--- a/flink-yarn-tests/src/main/java/org/apache/flink/yarn/UtilsTest.java
+++ b/flink-yarn-tests/src/main/java/org/apache/flink/yarn/UtilsTest.java
@@ -76,22 +76,27 @@ public class UtilsTest {
 			throw new NullPointerException("Initialize test appender first");
 		}
 		LoggingEvent found = null;
-		for(LoggingEvent event: testAppender.events) {
-			if(event.getMessage().toString().contains(expected)) {
-				found = event;
-				break;
+		// make sure that different threads are not logging while the logs are checked
+		synchronized (testAppender.events) {
+			for (LoggingEvent event : testAppender.events) {
+				if (event.getMessage().toString().contains(expected)) {
+					found = event;
+					break;
+				}
 			}
 		}
 		return found;
 	}
 
 	public static class TestAppender extends AppenderSkeleton {
-		public List<LoggingEvent> events = new ArrayList<LoggingEvent>();
+		public final List<LoggingEvent> events = new ArrayList<>();
 		public void close() {}
 		public boolean requiresLayout() {return false;}
 		@Override
 		protected void append(LoggingEvent event) {
-			events.add(event);
+			synchronized (events){
+				events.add(event);
+			}
 		}
 	}
 }


Mime
View raw message