Commit 5f626fcf by 章家宝

feat:dubbo 接口注解修改成广联接口

1 parent 0b33075f
...@@ -2,13 +2,13 @@ package cn.com.glsx.dj.supervisor.remote; ...@@ -2,13 +2,13 @@ package cn.com.glsx.dj.supervisor.remote;
import cn.com.glsx.dj.supervisor.dto.*; import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.service.SupervisorSpecialCoachApprovalService; import cn.com.glsx.dj.supervisor.service.SupervisorSpecialCoachApprovalService;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
...@@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* 用途:需求5.1 我的任务-专项带教申请审批 * 用途:需求5.1 我的任务-专项带教申请审批
*/ */
@Slf4j @Slf4j
@DubboService(retries = 0, timeout = 30000, validation = "true") @ApiService(value = "专项带教审批接口", owner = "supervisor", protocol = ApiService.ProtocolEnum.dubbo, version = "1.0.0")
public class SupervisorSpecialCoachApprovalRemoteImpl implements SupervisorSpecialCoachApprovalRemote { public class SupervisorSpecialCoachApprovalRemoteImpl implements SupervisorSpecialCoachApprovalRemote {
@Autowired @Autowired
......
...@@ -2,13 +2,13 @@ package cn.com.glsx.dj.supervisor.remote; ...@@ -2,13 +2,13 @@ package cn.com.glsx.dj.supervisor.remote;
import cn.com.glsx.dj.supervisor.dto.*; import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.service.SupervisorSpecialTaskService; import cn.com.glsx.dj.supervisor.service.SupervisorSpecialTaskService;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
...@@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* 用途:需求4.1 发起专项任务、需求4.2 查看我发起专项任务记录 * 用途:需求4.1 发起专项任务、需求4.2 查看我发起专项任务记录
*/ */
@Slf4j @Slf4j
@DubboService(retries = 0, timeout = 30000, validation = "true") @ApiService(value = "专项任务接口", owner = "supervisor", protocol = ApiService.ProtocolEnum.dubbo, version = "1.0.0")
public class SupervisorSpecialTaskRemoteImpl implements SupervisorSpecialTaskRemote { public class SupervisorSpecialTaskRemoteImpl implements SupervisorSpecialTaskRemote {
@Autowired @Autowired
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 2)

    1. Dubbo服务核心配置属性丢失(重试、超时、参数校验)

    • 问题描述:在将 @DubboService 替换为 @ApiService 的过程中,原注解中的核心控制属性 retries = 0, timeout = 30000, validation = "true" 全部丢失。
    • 影响分析:
      • 重试机制变化(高危):Dubbo 默认重试次数通常为 2 次,原代码特意设置为 0(不重试)。配置丢失将导致接口在网络抖动或处理缓慢时自动重试。如果这些接口包含非幂等的写操作(如审批、发起任务),极易导致数据重复插入或状态错乱。
      • 超时时间变化(高危):原代码设置了 30000ms(30秒)的长超时。配置丢失可能导致接口退化为默认超时时间(通常为 1000ms),这将导致原本耗时较长的业务逻辑在线上频繁抛出 TimeoutException,造成业务大面积阻断。
      • 参数校验失效:validation = "true" 丢失会导致基于 JSR303 的参数校验机制失效,非法参数可能直接穿透到业务层,引发空指针或越界等异常。
    • 优化建议:检查 @ApiService 注解是否支持这些属性的配置。如果支持,请在注解中补全;如果不支持,必须通过配置文件(如 application.yml)在服务级别或方法级别显式声明这些属性,或者与架构组确认 @ApiService 的正确集成姿势。 java // 示例:如果 @ApiService 支持,应补全属性,或者在配置文件中指定 @ApiService(value = "专项带教审批接口", owner = "supervisor", protocol = ApiService.ProtocolEnum.dubbo, version = "1.0.0", retries = 0, timeout = 30000, validation = "true")

    2. 提交信息缺乏修改背景与兼容性说明

    • 问题描述:Commit message 为 feat:dubbo 接口注解修改成广联接口 (by jiabao),仅说明了替换了注解,但没有说明为何替换,更没有提及对原有重要属性(timeout/retries)的处理策略。
    • 影响分析:当线上出现因为超时或重试导致的数据故障时,排查人员无法从提交历史中得知原有配置是被故意移除还是重构时的疏漏,降低了代码的可追溯性。
    • 优化建议:建议完善提交信息,清晰说明变更背景及兼容处理。例如:refactor: 统一使用框架 @ApiService 替换 @DubboService,原有 timeout/retries 等配置已迁移至统一配置中心(如果确实已做处理)。

    二、评分明细

    • 功能实现的正确性与健壮性(30/40分):扣 10 分。替换注解时遗漏了 retries=0 和 timeout=30000,严重破坏了原有接口的健壮性,极易在线上引发超时阻断和非幂等重试导致的数据异常。
    • 安全性与潜在风险(25/30分):扣 5 分。遗漏了 validation="true",导致 Dubbo 层面的参数校验保护层失效,增加了恶意或非法数据穿透到业务逻辑的风险。
    • 最佳实践与可维护性(15/20分):扣 5 分。向公司统一的框架注解迁移是良好的工程实践,但在重构时未仔细核对并平滑迁移原有属性,违背了安全重构的原则。
    • 性能与资源利用(4/5分):扣 1 分。由于重试机制可能被意外激活,在服务调用超时的情况下会产生不必要的重复请求,造成资源浪费。
    • 提交信息质量(3/5分):扣 2 分。提交信息过于简略,没有涵盖对关键配置变更的解释和说明。

    总分:77分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!