@@ -144,15 +144,21 @@ index bb8a4e8183..b9662fe6cd 100644
144144 connectionObject.getRunningFuture().get();
145145 } catch (IOException | InterruptedException | ExecutionException ex) {
146146diff --git a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/ConnectionSpecTest.java b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/ConnectionSpecTest.java
147- index f538c953f6..e008bcda0d 100644
147+ index f538c953f6..728228c63c 100644
148148--- a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/ConnectionSpecTest.java
149149+++ b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/ConnectionSpecTest.java
150- @@ -118,7 +118,7 @@ public class ConnectionSpecTest {
150+ @@ -118,10 +118,12 @@ public class ConnectionSpecTest {
151151 ByteArrayInputStream in = new ByteArrayInputStream(bytes);
152152 ByteArrayOutputStream os = new ByteArrayOutputStream();
153153 conn.prepare("Pipe server", in, os, new LspSession(), ConnectionSpecTest::setCopy, ConnectionSpecTest::copy);
154154- String reply = os.toString("UTF-8");
155- + String reply = os.toString("UTF-8".replaceAll("\n$", "") );
155+ + String reply = os.toString("UTF-8") .replaceAll("\n$", "");
156156 String exp = "Pipe server listening at port ";
157157 assertTrue(reply, reply.startsWith(exp));
158- int port = Integer.parseInt(reply.substring(exp.length(), reply.indexOf('\n', exp.length())));
158+ - int port = Integer.parseInt(reply.substring(exp.length(), reply.indexOf('\n', exp.length())));
159+ + int nextLineIdx = reply.indexOf('\n', exp.length());
160+ + if (nextLineIdx < 0) nextLineIdx = reply.length();
161+ + int port = Integer.parseInt(reply.substring(exp.length(), nextLineIdx));
162+ assertTrue("port is specified: " + port, port >= 1024);
163+ try (ConnectionSpec second = ConnectionSpec.parse("connect:" + port)) {
164+ second.prepare("Pipe client", in, os, new LspSession(), ConnectionSpecTest::setCopy, ConnectionSpecTest::copy);
0 commit comments