1
1
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/ConnectionSpec.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/ConnectionSpec.java
2
- index 9ab389564c..9b7c044c81 100644
2
+ index bb8a4e8183..b9662fe6cd 100644
3
3
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/ConnectionSpec.java
4
4
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/ConnectionSpec.java
5
5
@@ -25,7 +25,7 @@ import java.io.OutputStream;
@@ -86,11 +86,10 @@ index 9ab389564c..9b7c044c81 100644
86
86
} catch (IOException ex) {
87
87
if (isClosed(server)) {
88
88
break;
89
- @@ -129,26 +152,54 @@ final class ConnectionSpec implements Closeable {
90
- }
89
+ @@ -130,25 +153,53 @@ final class ConnectionSpec implements Closeable {
91
90
};
92
91
listeningThread.start();
93
- - out.write((prefix + " listening at port " + localPort).getBytes());
92
+ out.write((prefix + " listening at port " + localPort + "\n" ).getBytes());
94
93
+ StringBuilder message = new StringBuilder();
95
94
+ message.append(prefix).append(" listening at port ").append(localPort);
96
95
+ if (hash) {
@@ -128,7 +127,6 @@ index 9ab389564c..9b7c044c81 100644
128
127
+ if (hashContent != null) {
129
128
+ for (char c : hashContent) {
130
129
+ byte b = (byte) in.read();
131
- +
132
130
+ if (b != c) {
133
131
+ IOException toThrow = new IOException("Hash validation failed!");
134
132
+ try {
@@ -146,15 +144,21 @@ index 9ab389564c..9b7c044c81 100644
146
144
connectionObject.getRunningFuture().get();
147
145
} catch (IOException | InterruptedException | ExecutionException ex) {
148
146
diff --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
149
- index 1035cf9bc8..55c0488d03 100644
147
+ index f538c953f6..728228c63c 100644
150
148
--- a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/ConnectionSpecTest.java
151
149
+++ b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/ConnectionSpecTest.java
152
- @@ -118,7 +118,7 @@ public class ConnectionSpecTest {
150
+ @@ -118,10 +118,12 @@ public class ConnectionSpecTest {
153
151
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
154
152
ByteArrayOutputStream os = new ByteArrayOutputStream();
155
153
conn.prepare("Pipe server", in, os, new LspSession(), ConnectionSpecTest::setCopy, ConnectionSpecTest::copy);
156
154
- String reply = os.toString("UTF-8");
157
155
+ String reply = os.toString("UTF-8").replaceAll("\n$", "");
158
156
String exp = "Pipe server listening at port ";
159
157
assertTrue(reply, reply.startsWith(exp));
160
- int port = Integer.parseInt(reply.substring(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