Skip to content

Commit

Permalink
Merge pull request #17 from qupath/remove-log-when-opening-images
Browse files Browse the repository at this point in the history
Set log level to debug when opening images
  • Loading branch information
Rylern authored Feb 26, 2024
2 parents f4dde38 + e3cd3eb commit 7dc9367
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

ext.moduleName = 'qupath.extension.omero'
version = "0.1.0-rc3"
version = "0.1.0-rc4"
description = "QuPath extension to support image reading using OMERO APIs."
ext.qupathVersion = gradle.ext.qupathVersion
ext.qupathJavaVersion = 17
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/qupath/ext/omero/core/RequestSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private RequestSender() {
* @return whether the provided link is reachable
*/
public static CompletableFuture<Boolean> isLinkReachableWithGet(URI uri) {
return getGETRequest(uri)
return getGETRequest(uri, false)
.map(RequestSender::isLinkReachable)
.orElse(CompletableFuture.completedFuture(false));
}
Expand All @@ -95,7 +95,7 @@ public static CompletableFuture<Boolean> isLinkReachableWithOptions(URI uri) {
* @return the raw HTTP response with in text format, or an empty Optional if the request failed
*/
public static CompletableFuture<Optional<String>> get(URI uri) {
return getGETRequest(uri)
return getGETRequest(uri, true)
.map(RequestSender::request)
.orElse(CompletableFuture.completedFuture(Optional.empty()));
}
Expand Down Expand Up @@ -165,7 +165,7 @@ public static CompletableFuture<List<JsonElement>> getPaginated(URI uri) {
* @return the HTTP response converted to an image, or an empty Optional if the request or the conversion failed
*/
public static CompletableFuture<Optional<BufferedImage>> getImage(URI uri) {
var getRequest = getGETRequest(uri);
var getRequest = getGETRequest(uri, true);
if (getRequest.isPresent()) {
return httpClient
.sendAsync(getRequest.get(), HttpResponse.BodyHandlers.ofByteArray())
Expand Down Expand Up @@ -352,7 +352,7 @@ private static CompletableFuture<Optional<String>> request(HttpRequest request)
);
}

private static Optional<HttpRequest> getGETRequest(URI uri) {
private static Optional<HttpRequest> getGETRequest(URI uri, boolean logIfError) {
try {
return Optional.ofNullable(HttpRequest.newBuilder()
.uri(uri)
Expand All @@ -361,7 +361,9 @@ private static Optional<HttpRequest> getGETRequest(URI uri) {
.timeout(Duration.of(REQUEST_TIMEOUT, SECONDS))
.build());
} catch (Exception e) {
logger.error("Error when creating GET request", e);
if (logIfError) {
logger.error("Error when creating GET request", e);
}
return Optional.empty();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ private static Optional<WebClient> getClientAndCheckURIReachable(URI uri, String
if (client.getStatus().equals(WebClient.Status.SUCCESS)) {
return Optional.of(client);
} else {
logger.error("Client creation failed");
logger.debug("Client creation failed");
return Optional.empty();
}
} else {
logger.debug(String.format("Link %s not reachable; OMERO can't open it", uri));
return Optional.empty();
}
} catch (InterruptedException | ExecutionException e) {
Expand Down

0 comments on commit 7dc9367

Please sign in to comment.