From f25e535c04cb96800631fa606ff9d248e85ff816 Mon Sep 17 00:00:00 2001 From: wangchao Date: Mon, 3 Jul 2023 23:08:23 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9ACODE=20=E4=BD=BF=E7=94=A8=E8=87=AA?= =?UTF-8?q?=E5=A2=9E=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/user/service/impl/WebSocketServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java index d451d86..03cda4d 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java @@ -2,7 +2,6 @@ package com.abin.mallchat.custom.user.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; import cn.hutool.json.JSONUtil; import com.abin.mallchat.common.common.annotation.FrequencyControl; import com.abin.mallchat.common.common.config.ThreadPoolConfig; @@ -117,7 +116,7 @@ public class WebSocketServiceImpl implements WebSocketService { */ private Integer generateLoginCode(Channel channel) { do { - CODE.set(RandomUtil.randomInt(Integer.MAX_VALUE)); + CODE.getAndIncrement(); } while (WAIT_LOGIN_MAP.asMap().containsKey(CODE.get()) || Objects.isNull(WAIT_LOGIN_MAP.get(CODE.get(), c -> channel))); return CODE.get();