|
24 | 24 | import java.util.function.BiFunction;
|
25 | 25 |
|
26 | 26 | import org.awaitility.Awaitility;
|
| 27 | +import org.awaitility.core.ConditionTimeoutException; |
27 | 28 |
|
28 | 29 | import org.springframework.boot.devtools.RemoteSpringApplication;
|
29 | 30 | import org.springframework.boot.devtools.tests.JvmLauncher.LaunchedJvm;
|
@@ -77,7 +78,7 @@ private BiFunction<Integer, File, Process> getRemoteRestarter(JvmLauncher javaLa
|
77 | 78 | createRemoteSpringApplicationClassPath(classesDirectory),
|
78 | 79 | RemoteSpringApplication.class.getName(), "--spring.devtools.remote.secret=secret",
|
79 | 80 | "http://localhost:" + port);
|
80 |
| - awaitRemoteSpringApplication(remoteSpringApplicationJvm.getStandardOut()); |
| 81 | + awaitRemoteSpringApplication(remoteSpringApplicationJvm); |
81 | 82 | return remoteSpringApplicationJvm.getProcess();
|
82 | 83 | }
|
83 | 84 | catch (Exception ex) {
|
@@ -105,10 +106,22 @@ private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) throws Excepti
|
105 | 106 | .getServerPort();
|
106 | 107 | }
|
107 | 108 |
|
108 |
| - private void awaitRemoteSpringApplication(File standardOut) throws Exception { |
109 |
| - FileContents contents = new FileContents(standardOut); |
110 |
| - Awaitility.waitAtMost(Duration.ofSeconds(30)).until(contents::get, |
111 |
| - containsString("Started RemoteSpringApplication")); |
| 109 | + private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) throws Exception { |
| 110 | + FileContents contents = new FileContents(launchedJvm.getStandardOut()); |
| 111 | + try { |
| 112 | + Awaitility.waitAtMost(Duration.ofSeconds(30)).until(contents::get, |
| 113 | + containsString("Started RemoteSpringApplication")); |
| 114 | + } |
| 115 | + catch (ConditionTimeoutException ex) { |
| 116 | + if (!launchedJvm.getProcess().isAlive()) { |
| 117 | + throw new IllegalStateException( |
| 118 | + "Process exited with status " + launchedJvm.getProcess().exitValue() |
| 119 | + + " before producing expected standard output.\n\nStandard output:\n\n" + contents.get() |
| 120 | + + "\n\nStandard error:\n\n" + new FileContents(launchedJvm.getStandardError()).get(), |
| 121 | + ex); |
| 122 | + } |
| 123 | + throw ex; |
| 124 | + } |
112 | 125 | }
|
113 | 126 |
|
114 | 127 | }
|
0 commit comments