Сборка мусора в CachedAuthHandler

This commit is contained in:
Gravit 2018-09-19 19:55:49 +07:00
parent 2658c8a4ca
commit 4bdf6a2cbf

View file

@ -7,13 +7,17 @@
import java.util.UUID;
import ru.gravit.launcher.LauncherAPI;
import ru.gravit.launcher.NeedGarbageCollection;
import ru.gravit.launcher.managers.GarbageManager;
import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry;
import ru.gravit.launcher.serialize.config.entry.StringConfigEntry;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.SecurityHelper;
import ru.gravit.utils.helper.VerifyHelper;
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
public abstract class CachedAuthHandler extends AuthHandler {
public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection {
public static final class Entry {
@LauncherAPI
public final UUID uuid;
@ -36,6 +40,7 @@ public Entry(UUID uuid, String username, String accessToken, String serverID) {
@LauncherAPI
protected CachedAuthHandler(BlockConfigEntry block) {
super(block);
if(block.hasEntry("garbage")) if(block.getEntryValue("garbage", BooleanConfigEntry.class)) GarbageManager.registerNeedGC(this);
}
@LauncherAPI
@ -107,7 +112,10 @@ public synchronized boolean joinServer(String username, String accessToken, Stri
entry.serverID = serverID;
return true;
}
public synchronized void garbageCollection()
{
entryCache.clear();
}
@LauncherAPI
protected abstract boolean updateAuth(UUID uuid, String username, String accessToken) throws IOException;