Skip to content

Commit 03c0c3d

Browse files
calixtuskoppor
andcommitted
Fix issues by httpserver
Co-authored-by: Oliver Kopp <[email protected]>
1 parent f9fdde1 commit 03c0c3d

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import java.net.InetAddress;
44
import java.net.URI;
5+
import java.net.URISyntaxException;
56
import java.net.UnknownHostException;
67

78
import javafx.beans.property.BooleanProperty;
89
import javafx.beans.property.IntegerProperty;
910
import javafx.beans.property.SimpleBooleanProperty;
1011
import javafx.beans.property.SimpleIntegerProperty;
1112

13+
import org.jspecify.annotations.NonNull;
1214
import org.slf4j.Logger;
1315
import org.slf4j.LoggerFactory;
1416

@@ -75,12 +77,17 @@ public static InetAddress getIpAddress() throws UnknownHostException {
7577
return InetAddress.getByName("localhost");
7678
}
7779

78-
public URI getHttpServerUri() {
80+
public @NonNull URI getHttpServerUri() {
7981
try {
80-
return URI.create("http://" + RemotePreferences.getIpAddress().getHostAddress() + ":23119");
81-
} catch (UnknownHostException e) {
82+
return new URI("http://" + RemotePreferences.getIpAddress().getHostAddress() + ":23119");
83+
} catch (UnknownHostException | URISyntaxException e) {
8284
LOGGER.error("Could not create HTTP server URI. Falling back to default.", e);
83-
return URI.create("http://localhost:23119");
85+
try {
86+
return new URI("http://localhost:23119");
87+
} catch (URISyntaxException ex) {
88+
LOGGER.error("Should never happen, raw string is already valid uri");
89+
throw new RuntimeException(ex);
90+
}
8491
}
8592
}
8693
}

jabsrv/src/main/java/org/jabref/http/server/Server.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public HttpServer run(List<Path> files, URI uri) {
6262
// GUI uses HttpServerManager
6363
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
6464
try {
65-
System.out.println("Shutting down jabsrv...");
65+
LOGGER.debug("Shutting down jabsrv...");
6666
httpServer.shutdownNow();
67-
System.out.println("Done, exit.");
67+
LOGGER.debug("Done, exit.");
6868
} catch (Exception e) {
6969
LOGGER.error("Could not shut down server", e);
7070
}

jabsrv/src/main/java/org/jabref/http/server/cayw/CAYWResource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import javafx.application.Platform;
1919

20+
import org.jabref.architecture.AllowedToUseAwt;
2021
import org.jabref.http.server.cayw.format.FormatterService;
2122
import org.jabref.http.server.cayw.gui.CAYWEntry;
2223
import org.jabref.http.server.cayw.gui.SearchDialog;
@@ -40,6 +41,7 @@
4041
import org.slf4j.Logger;
4142
import org.slf4j.LoggerFactory;
4243

44+
@AllowedToUseAwt("Requires ava.awt.datatransfer.Clipboard")
4345
@Path("better-bibtex/cayw")
4446
public class CAYWResource {
4547
private static final Logger LOGGER = LoggerFactory.getLogger(CAYWResource.class);

0 commit comments

Comments
 (0)