* make sure to gracefully ignore all cache errors

This commit is contained in:
Reinhard Pointner 2012-07-11 20:17:58 +00:00
parent fa6909ddfe
commit 30f05c1f9c
1 changed files with 24 additions and 14 deletions

View File

@ -5,6 +5,8 @@ package net.sourceforge.filebot;
import java.awt.Image;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.Icon;
@ -77,18 +79,26 @@ public final class ResourceManager {
private static <T> T probeCache(String name, Class<T> type) {
try {
Element entry = cache.get(type.getName() + ":" + name);
if (entry != null) {
return type.cast(entry.getObjectValue());
}
} catch (Exception e) {
Logger.getLogger(ResourceManager.class.getName()).log(Level.WARNING, e.getMessage());
}
return null;
}
private static <T> T populateCache(String name, Class<? super T> type, T value) {
try {
cache.put(new Element(type.getName() + ":" + name, value));
} catch (Exception e) {
Logger.getLogger(ResourceManager.class.getName()).log(Level.WARNING, e.getMessage());
}
return value;
}