Skip to content

Commit

Permalink
Show throwing linkers as pending rather than idle/failing, fixed modu…
Browse files Browse the repository at this point in the history
…le dependency
  • Loading branch information
robertvazan committed Jan 20, 2024
1 parent f64c313 commit ed6272b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/machinezoo/foxcache/CacheReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,17 @@ public void show() {
entry.status = CacheStatus.RUNNING;
} else if (entry.input.blocking())
entry.status = CacheStatus.LINKING;
else if (entry.snapshot == null)
else if (entry.input.exception() != null) {
if (EmptyCacheException.caused(entry.input.exception()))
entry.status = CacheStatus.LINKING;
else
entry.status = CacheStatus.FAILED;
} else if (entry.snapshot == null)
entry.status = CacheStatus.EMPTY;
else if (entry.snapshot.cancelled()
&& ReactiveDuration.between(entry.snapshot.refreshed(), ReactiveInstant.now()).compareTo(Duration.ofSeconds(3)) < 0)
entry.status = CacheStatus.JUST_CANCELLED;
else if (entry.input.exception() != null || entry.snapshot.exception() != null)
else if (entry.snapshot.exception() != null)
entry.status = CacheStatus.FAILED;
else if (entry.snapshot.hash() == null)
entry.status = CacheStatus.EMPTY;
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/com/machinezoo/foxcache/EmptyCacheException.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// Part of Fox Cache: https://foxcache.machinezoo.com
package com.machinezoo.foxcache;

import org.apache.commons.lang3.exception.*;
import com.machinezoo.noexception.*;

public class EmptyCacheException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static class EmptyCacheExceptionSilencing extends ExceptionHandler {
@Override
public boolean handle(Throwable exception) {
return exception instanceof EmptyCacheException;
}
}
public static ExceptionHandler silence() {
return new EmptyCacheExceptionSilencing();
}
private static final long serialVersionUID = 1L;
public static boolean caused(Throwable exception) { return ExceptionUtils.stream(exception).anyMatch(x -> x instanceof EmptyCacheException); }
private static class EmptyCacheExceptionSilencing extends ExceptionHandler {
@Override public boolean handle(Throwable exception) { return caused(exception); }
}
public static ExceptionHandler silence() { return new EmptyCacheExceptionSilencing(); }
}
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
requires one.util.streamex;
requires com.google.common;
requires org.apache.commons.lang3;
requires org.apache.commons.collections4;
requires org.apache.commons.io;
requires org.objenesis;
requires org.slf4j;
Expand Down

0 comments on commit ed6272b

Please sign in to comment.