diff --git a/Common/source/customskinloader/CustomSkinLoader.java b/Common/source/customskinloader/CustomSkinLoader.java index b2f129e..ecbe1ec 100644 --- a/Common/source/customskinloader/CustomSkinLoader.java +++ b/Common/source/customskinloader/CustomSkinLoader.java @@ -2,9 +2,7 @@ package customskinloader; import java.io.File; import java.util.Map; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import com.google.common.collect.Maps; import com.google.gson.Gson; @@ -54,7 +52,20 @@ public class CustomSkinLoader { private static final ProfileCache profileCache=new ProfileCache(); private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager(); - private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>()); + //Correct thread name in thread pool + private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); + private static final ThreadFactory customFactory = r -> { + Thread t = defaultFactory.newThread(r); + if(r instanceof Thread) { + t.setName(((Thread) r).getName()); + } + return t; + }; + //Thread pool will discard oldest task when queue reaches 333 tasks + private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor( + config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, + new LinkedBlockingQueue<>(333), customFactory, new ThreadPoolExecutor.DiscardOldestPolicy() + ); //For User Skin public static Map loadProfile(GameProfile gameProfile){ diff --git a/Common/source/customskinloader/config/Config.java b/Common/source/customskinloader/config/Config.java index ec11218..48faa15 100644 --- a/Common/source/customskinloader/config/Config.java +++ b/Common/source/customskinloader/config/Config.java @@ -27,8 +27,8 @@ public class Config { public boolean forceIgnoreHttpsCertificate = false; public boolean forceLoadAllTextures=false; public boolean enableCape = true; - public int threadPoolSize = 1; - public int retryTime = 3; + public int threadPoolSize = 3; + public int retryTime = 1; //Cache public int cacheExpiry=30; diff --git a/Common/source/customskinloader/profile/ProfileCache.java b/Common/source/customskinloader/profile/ProfileCache.java index bb9a684..b520d95 100644 --- a/Common/source/customskinloader/profile/ProfileCache.java +++ b/Common/source/customskinloader/profile/ProfileCache.java @@ -59,7 +59,7 @@ public class ProfileCache { public void updateCache(String username,UserProfile profile,boolean saveLocalProfile){ CachedProfile cp=getCachedProfile(username); cp.profile=profile; - cp.expiryTime=TimeUtil.getUnixTimestampRandomDelay(CustomSkinLoader.config.cacheExpiry); + cp.expiryTime=TimeUtil.getUnixTimestamp(CustomSkinLoader.config.cacheExpiry); if(!saveLocalProfile) return; saveLocalProfile(username,profile);