Skip to content

Commit

Permalink
Wrong exception (#98)
Browse files Browse the repository at this point in the history
Catch exception from from PatronIdCache
Not from TokenCache from edge-common.
  • Loading branch information
adamdickmeiss authored Feb 1, 2023
1 parent fc715bf commit 2ff044e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/folio/edge/patron/cache/PatronIdCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ private PatronIdCache(long ttl, long nullTokenTtl, int capacity) {
}

/**
* Get the PatronIdCache singleton. the singleton must be initialize before
* Get the PatronIdCache singleton. the singleton must be initialized before
* calling this method.
*
* @see {@link #initialize(long, int)}
* @see {@link #initialize(long, long, int)}
*
* @return the PatronIdCache singleton instance.
*/
public static synchronized PatronIdCache getInstance() {
if (instance == null) {
throw new NotInitializedException(
throw new PatronIdCacheNotInitializedException(
"You must call PatronIdCache.initialize(ttl, capacity) before you can get the singleton instance");
}
return instance;
Expand Down Expand Up @@ -71,11 +71,11 @@ private String computeKey(String tenant, String externalId) {
return String.format("%s:%s", tenant, externalId);
}

public static class NotInitializedException extends RuntimeException {
public static class PatronIdCacheNotInitializedException extends RuntimeException {

private static final long serialVersionUID = 4747532964596334577L;

public NotInitializedException(String msg) {
public PatronIdCacheNotInitializedException(String msg) {
super(msg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.vertx.core.Future;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.edge.core.cache.TokenCache.NotInitializedException;
import org.folio.edge.patron.cache.PatronIdCache;

public class PatronIdHelper {
Expand All @@ -19,7 +18,7 @@ public static Future<String> lookupPatron(PatronOkapiClient client, String tenan
try {
PatronIdCache cache = PatronIdCache.getInstance();
patronId = cache.get(tenant, extPatronId);
} catch (NotInitializedException e) {
} catch (PatronIdCache.PatronIdCacheNotInitializedException e) {
logger.warn("Failed to access PatronIdCache", e);
}

Expand Down

0 comments on commit 2ff044e

Please sign in to comment.