Logging IOExceptions in main method.

This commit is contained in:
Sebastian Stenzel
2017-04-28 23:54:23 +02:00
parent d48247b7c6
commit e63cbf94d0
2 changed files with 7 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ public class Cryptomator {
private static final Logger LOG = LoggerFactory.getLogger(Cryptomator.class);
static final BlockingQueue<Path> FILE_OPEN_REQUESTS = new ArrayBlockingQueue<>(10);
public static void main(String[] args) throws IOException {
public static void main(String[] args) {
LOG.info("Starting Cryptomator {} on {} {} ({})", ApplicationVersion.orElse("SNAPSHOT"), SystemUtils.OS_NAME, SystemUtils.OS_VERSION, SystemUtils.OS_ARCH);
FileOpenRequestHandler fileOpenRequestHandler = new FileOpenRequestHandler(FILE_OPEN_REQUESTS);
@@ -30,6 +30,8 @@ public class Cryptomator {
communicator.handleLaunchArgs(args);
LOG.info("Found running application instance. Shutting down.");
}
} catch (IOException e) {
LOG.error("Failed to initiate inter-process communication.", e);
}
System.exit(0); // end remaining non-daemon threads.
}

View File

@@ -12,7 +12,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.rmi.ConnectException;
import java.rmi.NoSuchObjectException;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
@@ -113,7 +112,7 @@ abstract class InterProcessCommunicator implements InterProcessCommunicationProt
}
@Override
public void close() throws IOException {
public void close() {
// no-op
}
@@ -150,14 +149,14 @@ abstract class InterProcessCommunicator implements InterProcessCommunicationProt
}
@Override
public void close() throws IOException {
public void close() {
try {
registry.unbind(RMI_NAME);
UnicastRemoteObject.unexportObject(remote, true);
socket.close();
LOG.debug("Server shut down.");
} catch (NotBoundException | NoSuchObjectException e) {
// ignore
} catch (NotBoundException | IOException e) {
LOG.warn("Failed to close IPC Server.", e);
}
}