From 0d35144f865998e81ee39cb7b8face1c0723e728 Mon Sep 17 00:00:00 2001 From: Marcelo Vanzin Date: Fri, 29 Apr 2016 13:28:46 -0700 Subject: [PATCH] [SPARK-14391][launcher] Fix launcher communication test, take 2. There's actually a race here: the state of the handler was changed before the connection is set, so the test code could be notified of the state change, wake up, and still see the connection as null, triggering the assert. --- .../main/java/org/apache/spark/launcher/LauncherServer.java | 2 +- .../java/org/apache/spark/launcher/LauncherServerSuite.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java b/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java index 69fbf4387bdfb..e3413fd6652d8 100644 --- a/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java +++ b/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java @@ -298,8 +298,8 @@ protected void handle(Message msg) throws IOException { Hello hello = (Hello) msg; ChildProcAppHandle handle = pending.remove(hello.secret); if (handle != null) { - handle.setState(SparkAppHandle.State.CONNECTED); handle.setConnection(this); + handle.setState(SparkAppHandle.State.CONNECTED); this.handle = handle; } else { throw new IllegalArgumentException("Received Hello for unknown client."); diff --git a/launcher/src/test/java/org/apache/spark/launcher/LauncherServerSuite.java b/launcher/src/test/java/org/apache/spark/launcher/LauncherServerSuite.java index 22b834c5753a5..bfe1fcc87fe35 100644 --- a/launcher/src/test/java/org/apache/spark/launcher/LauncherServerSuite.java +++ b/launcher/src/test/java/org/apache/spark/launcher/LauncherServerSuite.java @@ -26,7 +26,6 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.*; @@ -62,7 +61,7 @@ public void testLauncherServerReuse() throws Exception { } } - @Ignore + @Test public void testCommunication() throws Exception { ChildProcAppHandle handle = LauncherServer.newAppHandle(); TestClient client = null;