Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Remote messaging #4760

Merged
merged 1 commit into from
Mar 15, 2019
Merged
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
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ private static boolean handleMultipleAppInstances(String[] args) {
// So we assume it's all taken care of, and quit.
LOGGER.info(Localization.lang("Arguments passed on to running JabRef instance. Shutting down."));
return false;
} else {
LOGGER.warn("Could not communicate with other running JabRef instance.");
}
} else {
// We are alone, so we start the server
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/jabref/gui/remote/JabRefMessageHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jabref.gui.remote;

import java.util.Arrays;
import java.util.List;

import javafx.application.Platform;
Expand All @@ -15,9 +14,6 @@ public class JabRefMessageHandler implements MessageHandler {
@Override
public void handleCommandLineArguments(String[] message) {
ArgumentProcessor argumentProcessor = new ArgumentProcessor(message, ArgumentProcessor.Mode.REMOTE_START);
if (!(argumentProcessor.hasParserResults())) {
throw new IllegalStateException("Could not start JabRef with arguments " + Arrays.toString(message));
}

List<ParserResult> loaded = argumentProcessor.getParserResults();
for (int i = 0; i < loaded.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.logic.remote.client;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;

import javafx.util.Pair;
Expand All @@ -17,8 +18,8 @@ public class RemoteClient {

private static final Logger LOGGER = LoggerFactory.getLogger(RemoteClient.class);

private static final int TIMEOUT = 2000;
private int port;
private static final int TIMEOUT = 200;
private final int port;

public RemoteClient(int port) {
this.port = port;
Expand Down Expand Up @@ -61,8 +62,9 @@ public boolean sendCommandLineArguments(String[] args) {
}

private Protocol openNewConnection() throws IOException {
Socket socket = new Socket(RemotePreferences.getIpAddress(), port);
Socket socket = new Socket();
socket.setSoTimeout(TIMEOUT);
socket.connect(new InetSocketAddress(RemotePreferences.getIpAddress(), port), TIMEOUT);
return new Protocol(socket);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RemoteListenerServer implements Runnable {

private static final int BACKLOG = 1;

private static final int ONE_SECOND_TIMEOUT = 1000;
private static final int TIMEOUT = 1000;

private final MessageHandler messageHandler;
private final ServerSocket serverSocket;
Expand All @@ -35,7 +35,7 @@ public void run() {
try {
while (!Thread.interrupted()) {
try (Socket socket = serverSocket.accept()) {
socket.setSoTimeout(ONE_SECOND_TIMEOUT);
socket.setSoTimeout(TIMEOUT);

try (Protocol protocol = new Protocol(socket)) {
Pair<RemoteMessage, Object> input = protocol.receiveMessage();
Expand Down