Move legacy field to class

This commit is contained in:
vemacs 2016-01-19 11:01:09 -07:00
parent a1d40f24a7
commit d895d40fbf

View file

@ -28,6 +28,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
private UUIDMap uuidMap; private UUIDMap uuidMap;
private final transient Cache<String, User> users; private final transient Cache<String, User> users;
private static boolean legacy = false;
public UserMap(final IEssentials ess) { public UserMap(final IEssentials ess) {
super(); super();
@ -37,7 +38,6 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
//users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().removalListener(remListener).build(this); //users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().removalListener(remListener).build(this);
CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder(); CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder();
int maxCount = ess.getSettings().getMaxUserCacheCount(); int maxCount = ess.getSettings().getMaxUserCacheCount();
boolean legacy = false;
try { try {
cacheBuilder.maximumSize(maxCount); cacheBuilder.maximumSize(maxCount);
} catch (NoSuchMethodError nsme) { } catch (NoSuchMethodError nsme) {
@ -107,9 +107,9 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
public User getUser(final UUID uuid) { public User getUser(final UUID uuid) {
try { try {
try { if (!legacy) {
return ((LoadingCache<String, User>) users).get(uuid.toString()); return ((LoadingCache<String, User>) users).get(uuid.toString());
} catch (SecurityException | ClassCastException e) { } else {
return legacyCacheGet(uuid); return legacyCacheGet(uuid);
} }
} catch (ExecutionException ex) { } catch (ExecutionException ex) {