Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
import java.net.Inet4Address;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.netbeans.api.sendopts.CommandException;
import org.openide.util.Exceptions;
Expand All @@ -44,6 +47,7 @@
"MSG_PortParseError=Cannot parse '{1}' as port in '{0}'"
})
final class ConnectionSpec implements Closeable {
private static final Logger LOG = Logger.getLogger(ConnectionSpec.class.getName());
private final Boolean listen;
private final int port;
private final List<Closeable> close = new ArrayList<>();
Expand Down Expand Up @@ -114,6 +118,11 @@ public void run() {
Socket socket = server.accept();
close.add(socket);
connectToSocket(socket, prefix, session, serverSetter, launcher);
} catch (SocketException se) {
if (server.isClosed()) {
LOG.log(Level.SEVERE, "Server failed to start on port {0}", port);
break;
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@
import org.junit.After;
import org.junit.Test;
import static org.junit.Assert.*;
import org.netbeans.junit.NbTestCase;
import org.netbeans.junit.RandomlyFails;

import org.openide.util.Pair;

public class ConnectionSpecTest {
@RandomlyFails
public class ConnectionSpecTest extends NbTestCase {

private static ThreadLocal<List<Boolean>> copySessionServer = new ThreadLocal<>();

public ConnectionSpecTest() {
public ConnectionSpecTest(String testName) {
super(testName);
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.MessageActionItem;
import org.eclipse.lsp4j.MessageParams;
import org.eclipse.lsp4j.MessageType;
import org.eclipse.lsp4j.ProgressParams;
import org.eclipse.lsp4j.PublishDiagnosticsParams;
import org.eclipse.lsp4j.SemanticTokensCapabilities;
Expand All @@ -61,6 +62,7 @@
import org.netbeans.api.sendopts.CommandLine;
import org.netbeans.api.templates.FileBuilder;
import org.netbeans.junit.NbTestCase;
import org.netbeans.junit.RandomlyFails;
import org.netbeans.modules.java.lsp.server.explorer.api.CreateExplorerParams;
import org.netbeans.modules.java.lsp.server.explorer.api.NodeChangedParams;
import org.netbeans.modules.java.lsp.server.explorer.api.NodeOperationParams;
Expand Down Expand Up @@ -90,6 +92,7 @@
*
* @author sdedic
*/
@RandomlyFails
public class ProjectViewTest extends NbTestCase {
private final Gson gson = new Gson();
private Socket clientSocket;
Expand Down Expand Up @@ -273,6 +276,19 @@ private static Launcher<NbLanguageServer> createLauncher(NbCodeLanguageClient cl
return new SemanticTokensParams(new TextDocumentIdentifier(""));
}
});
gb.registerTypeAdapter(NodeChangedParams.class, new InstanceCreator<NodeChangedParams>() {
@Override
public NodeChangedParams createInstance(Type type) {
return new NodeChangedParams(0);
}
});
gb.registerTypeAdapter(ShowStatusMessageParams.class, new InstanceCreator<ShowStatusMessageParams>() {
@Override
public ShowStatusMessageParams createInstance(Type type) {
return new ShowStatusMessageParams(MessageType.Error, "ShowStatusMessageParams default error message"); // NOI18N
}
});

})
.create();
}
Expand Down
Loading