diff --git a/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/manager/BlocklistServiceManager.java b/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/manager/BlocklistServiceManager.java index 8647d048d7..b55fbefb05 100644 --- a/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/manager/BlocklistServiceManager.java +++ b/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/manager/BlocklistServiceManager.java @@ -98,12 +98,12 @@ public class BlocklistServiceManager> { private static final long UNINITIALIZED_TIMESTAMP = -1; private static final int UNINITIALIZED_LOG_ID = -1; - private final RedisScript blockClientsScript; - private final RedisScript unblockClientsScript; - private final RedisScript getBlockedClientsScript; - private final RedisScript evictAllBlockedClients; - private final RedisScript evictExpiredBlockedClients; - private final RedisScript getBlocklistLogsScript; + private final RedisScript> blockClientsScript; + private final RedisScript> unblockClientsScript; + private final RedisScript> getBlockedClientsScript; + private final RedisScript evictAllBlockedClients; + private final RedisScript evictExpiredBlockedClients; + private final RedisScript> getBlocklistLogsScript; private final Node node; private final TurmsRedisClient redisClient; @@ -138,12 +138,12 @@ public BlocklistServiceManager( Node node, TurmsRedisClient redisClient, ScheduledThreadPoolExecutor threadPoolExecutor, - RedisScript blockClientsScript, - RedisScript unblockClientsScript, - RedisScript getBlockedClientsScript, - RedisScript evictAllBlockedClients, - RedisScript evictExpiredBlockedClients, - RedisScript getBlocklistLogsScript, + RedisScript> blockClientsScript, + RedisScript> unblockClientsScript, + RedisScript> getBlockedClientsScript, + RedisScript evictAllBlockedClients, + RedisScript evictExpiredBlockedClients, + RedisScript> getBlocklistLogsScript, Consumer onTargetBlocked) { this.node = node; this.redisClient = redisClient; @@ -262,7 +262,8 @@ private void removeLocalBlockedClient(T targetId) { public Mono unblockAll() { blockedClientIdToBlockEndTimeMillis.clear(); blockedClientSkipList.clear(); - return redisClient.eval(evictAllBlockedClients, getBlocklistKey()); + return redisClient.eval(evictAllBlockedClients, getBlocklistKey()) + .then(); } private void evictLocalExpiredBlockedClients() { diff --git a/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/service/BlocklistService.java b/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/service/BlocklistService.java index e4f863bcb5..5f0f9be677 100644 --- a/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/service/BlocklistService.java +++ b/turms-server-common/src/main/java/im/turms/server/common/domain/blocklist/service/BlocklistService.java @@ -112,24 +112,24 @@ public BlocklistService( Map params = Map.of("MAX_LOG_QUEUE_SIZE", maxLogQueueSize); - RedisScript blockClientsScript = + RedisScript> blockClientsScript = RedisScript.get(new ClassPathResource("redis/blocklist/block_clients.lua"), ScriptOutputType.MULTI, params); - RedisScript unblockClientsScript = + RedisScript> unblockClientsScript = RedisScript.get(new ClassPathResource("redis/blocklist/unblock_clients.lua"), ScriptOutputType.MULTI, params); - RedisScript getBlockedClientsScript = + RedisScript> getBlockedClientsScript = RedisScript.get(new ClassPathResource("redis/blocklist/get_blocked_clients.lua"), ScriptOutputType.MULTI); - RedisScript evictAllBlockedClients = RedisScript.get( + RedisScript evictAllBlockedClients = RedisScript.get( new ClassPathResource("redis/blocklist/evict_all_blocked_clients.lua"), ScriptOutputType.BOOLEAN); - RedisScript evictExpiredBlockedClients = RedisScript.get( + RedisScript evictExpiredBlockedClients = RedisScript.get( new ClassPathResource("redis/blocklist/evict_expired_blocked_clients.lua"), ScriptOutputType.BOOLEAN); - RedisScript getBlocklistLogsScript = + RedisScript> getBlocklistLogsScript = RedisScript.get(new ClassPathResource("redis/blocklist/get_blocklist_logs.lua"), ScriptOutputType.MULTI, params); diff --git a/turms-service/src/main/java/im/turms/service/domain/common/service/CustomSettingService.java b/turms-service/src/main/java/im/turms/service/domain/common/service/CustomSettingService.java index d88e29c5be..0ccf9a2bc3 100644 --- a/turms-service/src/main/java/im/turms/service/domain/common/service/CustomSettingService.java +++ b/turms-service/src/main/java/im/turms/service/domain/common/service/CustomSettingService.java @@ -37,7 +37,7 @@ import im.turms.server.common.infra.property.env.service.business.common.setting.CustomSettingProperties; import im.turms.server.common.infra.property.env.service.business.common.setting.CustomSettingStringValueProperties; import im.turms.server.common.infra.property.env.service.business.common.setting.CustomSettingValueProperties; -import im.turms.service.infra.locale.LocaleUtils; +import im.turms.service.infra.locale.LocaleUtil; /** * @author James Chen @@ -261,7 +261,7 @@ private Object parseValue( }; case LANGUAGE -> { String languageId = value.getStringValue(); - if (!LocaleUtils.isAvailableLanguage(languageId)) { + if (!LocaleUtil.isAvailableLanguage(languageId)) { throw ResponseException.get(ResponseStatusCode.ILLEGAL_ARGUMENT, "The value of the setting \"" + sourceName diff --git a/turms-service/src/main/java/im/turms/service/infra/locale/LocaleUtils.java b/turms-service/src/main/java/im/turms/service/infra/locale/LocaleUtil.java similarity index 88% rename from turms-service/src/main/java/im/turms/service/infra/locale/LocaleUtils.java rename to turms-service/src/main/java/im/turms/service/infra/locale/LocaleUtil.java index 2c2a9c63b3..c5dc7863c1 100644 --- a/turms-service/src/main/java/im/turms/service/infra/locale/LocaleUtils.java +++ b/turms-service/src/main/java/im/turms/service/infra/locale/LocaleUtil.java @@ -24,19 +24,19 @@ /** * @author James Chen */ -public final class LocaleUtils { +public final class LocaleUtil { private static final Map ID_TO_LOCALE; static { Map idToLocale = new HashMap<>(2048); - // Use "availableLocales()" to avoid unnecessary copy. + // Use "availableLocales()" instead of "getAvailableLocales()" to avoid unnecessary copy. Locale.availableLocales() .forEach(locale -> idToLocale.put(locale.toLanguageTag(), locale)); ID_TO_LOCALE = Map.copyOf(idToLocale); } - private LocaleUtils() { + private LocaleUtil() { } public static boolean isAvailableLanguage(String languageId) {