From cde93002842d8ddb211b430f84a8fc9df3e51d32 Mon Sep 17 00:00:00 2001 From: cmgyqjj Date: Fri, 20 Sep 2024 16:36:49 +0800 Subject: [PATCH 1/6] fix:User_Logout_NPE --- .../cim/route/controller/RouteController.java | 8 +++++--- .../cim/route/service/UserInfoCacheService.java | 8 ++++++++ .../cim/route/service/impl/UserInfoCacheServiceImpl.java | 5 +++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java index e655473e..145a6c3f 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java @@ -131,10 +131,12 @@ public BaseResponse p2pRoute(@RequestBody P2PReqVO p2pRequest) throws public BaseResponse offLine(@RequestBody ChatReqVO groupReqVO) { BaseResponse res = new BaseResponse(); - CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); + if(userInfoCacheService.CheckUserLoginStatus(groupReqVO.getUserId())){ + CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); - log.info("user [{}] offline!", cimUserInfo.toString()); - accountService.offLine(groupReqVO.getUserId()); + log.info("user [{}] offline!", cimUserInfo.toString()); + accountService.offLine(groupReqVO.getUserId()); + } res.setCode(StatusEnum.SUCCESS.getCode()); res.setMessage(StatusEnum.SUCCESS.getMessage()); diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java index a76e7da0..988b7d08 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java @@ -29,6 +29,14 @@ public interface UserInfoCacheService { */ boolean saveAndCheckUserLoginStatus(Long userId) throws Exception ; + /** + * 检查用户登录情况 + * @param userId userId 用户唯一 ID + * @return true 为已登录 false 为未登录 + * @throws Exception + */ + boolean CheckUserLoginStatus(Long userId) ; + /** * 清除用户的登录状态 * @param userId diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java index cfbe4b97..b14b8b2f 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java @@ -63,6 +63,11 @@ public boolean saveAndCheckUserLoginStatus(Long userId) throws Exception { } } + @Override + public boolean CheckUserLoginStatus(Long userId){ + return redisTemplate.opsForSet().isMember(LOGIN_STATUS_PREFIX, userId.toString()); + } + @Override public void removeLoginStatus(Long userId) { redisTemplate.opsForSet().remove(LOGIN_STATUS_PREFIX,userId.toString()) ; From 710c1dc24d360dca74d915ab7dfd3ebf98d412d6 Mon Sep 17 00:00:00 2001 From: cmgyqjj Date: Sat, 21 Sep 2024 19:37:23 +0800 Subject: [PATCH 2/6] fix:User_Logout_NPE --- .../cim/client/sdk/ClientTest.java | 22 +++++++++++++++++++ .../cim/route/controller/RouteController.java | 7 +++--- .../route/service/UserInfoCacheService.java | 11 ++-------- .../service/impl/AccountServiceRedisImpl.java | 5 +++-- .../impl/UserInfoCacheServiceImpl.java | 16 +++++--------- 5 files changed, 37 insertions(+), 24 deletions(-) diff --git a/cim-client-sdk/src/test/java/com/crossoverjie/cim/client/sdk/ClientTest.java b/cim-client-sdk/src/test/java/com/crossoverjie/cim/client/sdk/ClientTest.java index 7685698f..bc51afaf 100644 --- a/cim-client-sdk/src/test/java/com/crossoverjie/cim/client/sdk/ClientTest.java +++ b/cim-client-sdk/src/test/java/com/crossoverjie/cim/client/sdk/ClientTest.java @@ -395,4 +395,26 @@ public void testClose() throws Exception { super.stopSingle(); } + @Test + public void testIncorrectUser() throws Exception { + super.starSingleServer(); + super.startRoute(); + String routeUrl = "http://localhost:8083"; + String cj = "xx"; + long id = 100L; + var auth1 = ClientConfigurationData.Auth.builder() + .userId(id) + .userName(cj) + .build(); + + Client client1 = Client.builder() + .auth(auth1) + .routeUrl(routeUrl) + .build(); + TimeUnit.SECONDS.sleep(3); + + Assertions.assertDoesNotThrow(client1::close); + + super.stopSingle(); + } } \ No newline at end of file diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java index 145a6c3f..3be26cce 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java @@ -23,6 +23,7 @@ import jakarta.annotation.Resource; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -75,7 +76,7 @@ public BaseResponse groupRoute(@RequestBody ChatReqVO groupReqVO) thro CIMServerResVO cimServerResVO = cimServerResVOEntry.getValue(); if (userId.equals(groupReqVO.getUserId())) { //过滤掉自己 - CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); + Optional cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); log.warn("过滤掉了发送者 userId={}", cimUserInfo.toString()); continue; } @@ -131,9 +132,9 @@ public BaseResponse p2pRoute(@RequestBody P2PReqVO p2pRequest) throws public BaseResponse offLine(@RequestBody ChatReqVO groupReqVO) { BaseResponse res = new BaseResponse(); - if(userInfoCacheService.CheckUserLoginStatus(groupReqVO.getUserId())){ - CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); + Optional cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); + if(cimUserInfo.isPresent()){ log.info("user [{}] offline!", cimUserInfo.toString()); accountService.offLine(groupReqVO.getUserId()); } diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java index 76c49673..a0c57a42 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/UserInfoCacheService.java @@ -2,6 +2,7 @@ import com.crossoverjie.cim.common.pojo.CIMUserInfo; +import java.util.Optional; import java.util.Set; /** @@ -19,7 +20,7 @@ public interface UserInfoCacheService { * @return * @throws Exception */ - CIMUserInfo loadUserInfoByUserId(Long userId) ; + Optional loadUserInfoByUserId(Long userId) ; /** * 保存和检查用户登录情况 @@ -29,14 +30,6 @@ public interface UserInfoCacheService { */ boolean saveAndCheckUserLoginStatus(Long userId) throws Exception ; - /** - * 检查用户登录情况 - * @param userId userId 用户唯一 ID - * @return true 为已登录 false 为未登录 - * @throws Exception - */ - boolean CheckUserLoginStatus(Long userId) ; - /** * query all online user * @return online user diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java index b707f849..7eed9316 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java @@ -31,6 +31,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import static com.crossoverjie.cim.common.enums.StatusEnum.OFF_LINE; import static com.crossoverjie.cim.route.constant.Constant.*; @@ -150,11 +151,11 @@ private void parseServerInfo(Map routes, String key) { @Override public void pushMsg(CIMServerResVO cimServerResVO, long sendUserId, ChatReqVO groupReqVO) throws Exception { - CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(sendUserId); + Optional cimUserInfo = userInfoCacheService.loadUserInfoByUserId(sendUserId); String url = "http://" + cimServerResVO.getIp() + ":" + cimServerResVO.getHttpPort(); ServerApi serverApi = RpcProxyManager.create(ServerApi.class, okHttpClient); - SendMsgReqVO vo = new SendMsgReqVO(cimUserInfo.getUserName() + ":" + groupReqVO.getMsg(), groupReqVO.getUserId()); + SendMsgReqVO vo = new SendMsgReqVO(cimUserInfo.get().getUserName() + ":" + groupReqVO.getMsg(), groupReqVO.getUserId()); serverApi.sendMsg(vo, url); } diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java index 9ebf5781..41fa9217 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -34,12 +35,12 @@ public class UserInfoCacheServiceImpl implements UserInfoCacheService { private RedisTemplate redisTemplate ; @Override - public CIMUserInfo loadUserInfoByUserId(Long userId) { + public Optional loadUserInfoByUserId(Long userId) { //优先从本地缓存获取 CIMUserInfo cimUserInfo = USER_INFO_MAP.get(userId); if (cimUserInfo != null){ - return cimUserInfo ; + return Optional.ofNullable(cimUserInfo); } //load redis @@ -49,7 +50,7 @@ public CIMUserInfo loadUserInfoByUserId(Long userId) { USER_INFO_MAP.put(userId,cimUserInfo) ; } - return cimUserInfo; + return Optional.ofNullable(cimUserInfo); } @Override @@ -63,11 +64,6 @@ public boolean saveAndCheckUserLoginStatus(Long userId) throws Exception { } } - @Override - public boolean CheckUserLoginStatus(Long userId){ - return redisTemplate.opsForSet().isMember(LOGIN_STATUS_PREFIX, userId.toString()); - } - @Override public Set onlineUser() { Set set = null ; @@ -76,8 +72,8 @@ public Set onlineUser() { if (set == null){ set = new HashSet<>(64) ; } - CIMUserInfo cimUserInfo = loadUserInfoByUserId(Long.valueOf(member)) ; - set.add(cimUserInfo) ; + Optional cimUserInfo = loadUserInfoByUserId(Long.valueOf(member)) ; + set.add(cimUserInfo.get()) ; } return set; From 8c925a445ac668311d3d3f6fc128723d78c43c30 Mon Sep 17 00:00:00 2001 From: cmgyqjj Date: Sat, 21 Sep 2024 19:56:24 +0800 Subject: [PATCH 3/6] fix:User_Logout_NPE --- .../cim/route/service/impl/UserInfoCacheServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java index 41fa9217..72f461df 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java @@ -73,7 +73,8 @@ public Set onlineUser() { set = new HashSet<>(64) ; } Optional cimUserInfo = loadUserInfoByUserId(Long.valueOf(member)) ; - set.add(cimUserInfo.get()) ; + + cimUserInfo.ifPresentOrElse(set::add, () -> {}); } return set; From 54b815b2c4fa79e41832d3fcf677ee1e896bc048 Mon Sep 17 00:00:00 2001 From: cmgyqjj Date: Sat, 21 Sep 2024 22:39:18 +0800 Subject: [PATCH 4/6] fix_User_Logout_NPE --- .../cim/route/controller/RouteController.java | 8 ++++---- .../service/impl/AccountServiceRedisImpl.java | 15 ++++++++++----- .../service/impl/UserInfoCacheServiceImpl.java | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java index 3be26cce..28c54bce 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java @@ -77,7 +77,7 @@ public BaseResponse groupRoute(@RequestBody ChatReqVO groupReqVO) thro if (userId.equals(groupReqVO.getUserId())) { //过滤掉自己 Optional cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); - log.warn("过滤掉了发送者 userId={}", cimUserInfo.toString()); + cimUserInfo.ifPresent(userInfo -> log.warn("过滤掉了发送者 userId={}", userInfo.toString())); continue; } @@ -134,10 +134,10 @@ public BaseResponse offLine(@RequestBody ChatReqVO groupReqVO) { Optional cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); - if(cimUserInfo.isPresent()){ - log.info("user [{}] offline!", cimUserInfo.toString()); + cimUserInfo.ifPresent(userInfo -> { + log.info("user [{}] offline!", userInfo.toString()); accountService.offLine(groupReqVO.getUserId()); - } + }); res.setCode(StatusEnum.SUCCESS.getCode()); res.setMessage(StatusEnum.SUCCESS.getMessage()); diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java index e3daf940..39b7a314 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java @@ -157,11 +157,16 @@ private void parseServerInfo(Map routes, String key) { public void pushMsg(CIMServerResVO cimServerResVO, long sendUserId, ChatReqVO groupReqVO) throws Exception { Optional cimUserInfo = userInfoCacheService.loadUserInfoByUserId(sendUserId); - String url = "http://" + cimServerResVO.getIp() + ":" + cimServerResVO.getHttpPort(); - ServerApi serverApi = RpcProxyManager.create(ServerApi.class, okHttpClient); - SendMsgReqVO vo = new SendMsgReqVO(cimUserInfo.get().getUserName() + ":" + groupReqVO.getMsg(), groupReqVO.getUserId()); - - serverApi.sendMsg(vo, url); + cimUserInfo.ifPresent(userInfo -> { + String url = "http://" + cimServerResVO.getIp() + ":" + cimServerResVO.getHttpPort(); + SendMsgReqVO vo = new SendMsgReqVO(userInfo.getUserName() + ":" + groupReqVO.getMsg(), groupReqVO.getUserId()); + try { + serverApi.sendMsg(vo, url); + } catch (Exception e) { + log.error("Error sending message", e); + throw new RuntimeException("Error sending message", e); + } + }); } @Override diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java index 72f461df..5f32e585 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java @@ -74,7 +74,7 @@ public Set onlineUser() { } Optional cimUserInfo = loadUserInfoByUserId(Long.valueOf(member)) ; - cimUserInfo.ifPresentOrElse(set::add, () -> {}); + cimUserInfo.ifPresent(set::add); } return set; From f92dfcf2f7a86eaf4320feb7ae08307fd9ace20d Mon Sep 17 00:00:00 2001 From: crossoverJie Date: Sun, 22 Sep 2024 11:02:50 +0800 Subject: [PATCH 5/6] remove unless exception --- .../cim/route/controller/RouteController.java | 4 ++-- .../cim/route/service/AccountService.java | 2 +- .../service/impl/AccountServiceRedisImpl.java | 19 +++++++++---------- .../impl/UserInfoCacheServiceImpl.java | 2 +- .../crossoverjie/cim/route/api/RouteApi.java | 4 ++-- .../cim/server/api/ServerApi.java | 2 +- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java index 28c54bce..3b183518 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/controller/RouteController.java @@ -64,7 +64,7 @@ public class RouteController implements RouteApi { @RequestMapping(value = "groupRoute", method = RequestMethod.POST) @ResponseBody() @Override - public BaseResponse groupRoute(@RequestBody ChatReqVO groupReqVO) throws Exception { + public BaseResponse groupRoute(@RequestBody ChatReqVO groupReqVO) { BaseResponse res = new BaseResponse(); log.info("msg=[{}]", groupReqVO.toString()); @@ -103,7 +103,7 @@ public BaseResponse groupRoute(@RequestBody ChatReqVO groupReqVO) thro @RequestMapping(value = "p2pRoute", method = RequestMethod.POST) @ResponseBody() @Override - public BaseResponse p2pRoute(@RequestBody P2PReqVO p2pRequest) throws Exception { + public BaseResponse p2pRoute(@RequestBody P2PReqVO p2pRequest) { BaseResponse res = new BaseResponse(); try { diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/AccountService.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/AccountService.java index 227d37f0..45c2738b 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/AccountService.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/AccountService.java @@ -62,7 +62,7 @@ public interface AccountService { * @param sendUserId 发送者的ID * @throws Exception */ - void pushMsg(CIMServerResVO cimServerResVO, long sendUserId , ChatReqVO groupReqVO) throws Exception; + void pushMsg(CIMServerResVO cimServerResVO, long sendUserId , ChatReqVO groupReqVO); /** * 用户下线 diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java index 39b7a314..b7ab72f8 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java @@ -140,7 +140,8 @@ public CIMServerResVO loadRouteRelatedByUserId(Long userId) { } RouteInfo parse = RouteInfoParseUtil.parse(value); - CIMServerResVO cimServerResVO = new CIMServerResVO(parse.getIp(), parse.getCimServerPort(), parse.getHttpPort()); + CIMServerResVO cimServerResVO = + new CIMServerResVO(parse.getIp(), parse.getCimServerPort(), parse.getHttpPort()); return cimServerResVO; } @@ -148,24 +149,22 @@ private void parseServerInfo(Map routes, String key) { long userId = Long.valueOf(key.split(":")[1]); String value = redisTemplate.opsForValue().get(key); RouteInfo parse = RouteInfoParseUtil.parse(value); - CIMServerResVO cimServerResVO = new CIMServerResVO(parse.getIp(), parse.getCimServerPort(), parse.getHttpPort()); + CIMServerResVO cimServerResVO = + new CIMServerResVO(parse.getIp(), parse.getCimServerPort(), parse.getHttpPort()); routes.put(userId, cimServerResVO); } @Override - public void pushMsg(CIMServerResVO cimServerResVO, long sendUserId, ChatReqVO groupReqVO) throws Exception { + public void pushMsg(CIMServerResVO cimServerResVO, long sendUserId, ChatReqVO groupReqVO) { Optional cimUserInfo = userInfoCacheService.loadUserInfoByUserId(sendUserId); cimUserInfo.ifPresent(userInfo -> { String url = "http://" + cimServerResVO.getIp() + ":" + cimServerResVO.getHttpPort(); - SendMsgReqVO vo = new SendMsgReqVO(userInfo.getUserName() + ":" + groupReqVO.getMsg(), groupReqVO.getUserId()); - try { - serverApi.sendMsg(vo, url); - } catch (Exception e) { - log.error("Error sending message", e); - throw new RuntimeException("Error sending message", e); - } + SendMsgReqVO vo = + new SendMsgReqVO(userInfo.getUserName() + ":" + groupReqVO.getMsg(), groupReqVO.getUserId()); + serverApi.sendMsg(vo, url); + }); } diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java index 5f32e585..2f27938c 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/UserInfoCacheServiceImpl.java @@ -40,7 +40,7 @@ public Optional loadUserInfoByUserId(Long userId) { //优先从本地缓存获取 CIMUserInfo cimUserInfo = USER_INFO_MAP.get(userId); if (cimUserInfo != null){ - return Optional.ofNullable(cimUserInfo); + return Optional.of(cimUserInfo); } //load redis diff --git a/cim-rout-api/src/main/java/com/crossoverjie/cim/route/api/RouteApi.java b/cim-rout-api/src/main/java/com/crossoverjie/cim/route/api/RouteApi.java index 12bf8a06..7c5fd05b 100644 --- a/cim-rout-api/src/main/java/com/crossoverjie/cim/route/api/RouteApi.java +++ b/cim-rout-api/src/main/java/com/crossoverjie/cim/route/api/RouteApi.java @@ -28,7 +28,7 @@ public interface RouteApi { * @return * @throws Exception */ - BaseResponse groupRoute(ChatReqVO groupReqVO) throws Exception; + BaseResponse groupRoute(ChatReqVO groupReqVO); /** * Point to point chat @@ -36,7 +36,7 @@ public interface RouteApi { * @return * @throws Exception */ - BaseResponse p2pRoute(P2PReqVO p2pRequest) throws Exception; + BaseResponse p2pRoute(P2PReqVO p2pRequest); /** diff --git a/cim-server-api/src/main/java/com/crossoverjie/cim/server/api/ServerApi.java b/cim-server-api/src/main/java/com/crossoverjie/cim/server/api/ServerApi.java index 4e459cb7..15e83ecc 100644 --- a/cim-server-api/src/main/java/com/crossoverjie/cim/server/api/ServerApi.java +++ b/cim-server-api/src/main/java/com/crossoverjie/cim/server/api/ServerApi.java @@ -20,5 +20,5 @@ public interface ServerApi { * @return * @throws Exception */ - BaseResponse sendMsg(SendMsgReqVO sendMsgReqVO, @DynamicUrl String url) throws Exception; + BaseResponse sendMsg(SendMsgReqVO sendMsgReqVO, @DynamicUrl String url); } From 218d1d41eb14dc681f877f7b1812d12103e1fd0f Mon Sep 17 00:00:00 2001 From: crossoverJie Date: Sun, 22 Sep 2024 11:03:32 +0800 Subject: [PATCH 6/6] remove unless code --- .../cim/route/service/impl/AccountServiceRedisImpl.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java index b7ab72f8..3ab5300b 100644 --- a/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java +++ b/cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java @@ -54,9 +54,6 @@ public class AccountServiceRedisImpl implements AccountService { @Resource private UserInfoCacheService userInfoCacheService; - @Resource - private OkHttpClient okHttpClient; - @Resource private ServerApi serverApi;