You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/06/27 13:50:09 UTC

[GitHub] [flink] StefanRRichter commented on a change in pull request #8858: [hotfix][tests] Change some StreamTask tests to create a test task in the task's thread

StefanRRichter commented on a change in pull request #8858: [hotfix][tests] Change some StreamTask tests to create a test task in the task's thread
URL: https://github.com/apache/flink/pull/8858#discussion_r298187538
 
 

 ##########
 File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTestHarness.java
 ##########
 @@ -231,15 +230,20 @@ public Thread invoke() throws Exception {
 	 *
 	 */
 	public Thread invoke(StreamMockEnvironment mockEnv) throws Exception {
+		checkState(this.mockEnv == null);
+		checkState(this.taskThread == null);
 		this.mockEnv = checkNotNull(mockEnv);
 
 		initializeInputs();
 		initializeOutput();
 
-		this.task = taskFactory.apply(mockEnv);
-
-		taskThread = new TaskThread(task);
+		taskThread = new TaskThread(() -> taskFactory.apply(mockEnv));
 		taskThread.start();
+		// Wait until the task is set
+		while (taskThread.task == null) {
+			Thread.sleep(10L);
 
 Review comment:
   Nit: Why not use a latch like `OneShotLatch` here to wait-block until the field is set and the thread then signals?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services