Skip to content

Commit

Permalink
Improve Remote messaging (#4760)
Browse files Browse the repository at this point in the history
Fixes #4023 and should fix #4481.
  • Loading branch information
tobiasdiez authored and Siedlerchr committed Mar 15, 2019
1 parent 031e962 commit 46d2c7d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
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

0 comments on commit 46d2c7d

Please sign in to comment.