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

[WIP] First attempt at fixing second jabref instance detection #4460

Closed
wants to merge 2 commits into from
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
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void start(Stage mainStage) throws Exception {
// Check for running JabRef
if (!handleMultipleAppInstances(arguments) || argumentProcessor.shouldShutDown()) {
Platform.exit();
return;
}

// If not, start GUI
Expand All @@ -79,13 +78,13 @@ public void start(Stage mainStage) throws Exception {
LOGGER.error("Unexpected exception", ex);
}
}

@Override
public void stop() {
Globals.stopBackgroundTasks();
Globals.shutdownThreadPools();
}

/**
* Tests if we are running an acceptable Java and terminates JabRef when we are sure the version is not supported.
* This test uses the requirements for the Java version as specified in <code>gradle.build</code>. It is possible to
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 org.jabref.JabRefGUI;
Expand All @@ -13,9 +12,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
10 changes: 5 additions & 5 deletions src/main/java/org/jabref/logic/remote/client/RemoteClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,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 = 5000;
private final int port;

public RemoteClient(int port) {
this.port = port;
Expand All @@ -29,7 +29,7 @@ public boolean ping() {
protocol.sendMessage(RemoteMessage.PING);
Pair<RemoteMessage, Object> response = protocol.receiveMessage();

if (response.getKey() == RemoteMessage.PONG && Protocol.IDENTIFIER.equals(response.getValue())) {
if ((response.getKey() == RemoteMessage.PONG) && Protocol.IDENTIFIER.equals(response.getValue())) {
return true;
} else {
String port = String.valueOf(this.port);
Expand All @@ -47,7 +47,7 @@ public boolean ping() {
* Attempt to send command line arguments to already running JabRef instance.
*
* @param args command line arguments.
* @return true if successful, false otherwise.
* @return true
*/
public boolean sendCommandLineArguments(String[] args) {
try (Protocol protocol = openNewConnection()) {
Expand All @@ -56,7 +56,7 @@ public boolean sendCommandLineArguments(String[] args) {
return response.getKey() == RemoteMessage.OK;
} catch (IOException e) {
LOGGER.debug("Could not send args " + String.join(", ", args) + " to the server at port " + port, e);
return false;
return true;
}
}

Expand Down