Repository navigation
Conversation
ChannelNoticeController#doReturn 是返回视图名的 @controller 方法,先调用 response.sendRedirect() 再返回 null,响应已提交后 Spring MVC 仍会按请求路径 推导视图名并解析静态资源,产生 NoResourceFoundException(response committed already)告警。改为返回 "redirect:" + url,由 Spring MVC 统一处理重定向。 onlyJump 同样改为返回视图名(直接跳转地址或支付结果页),并补上原先被忽略的 toReturnPage 返回值,避免订单不存在时继续执行导致的空指针。 同时补充 ChannelNoticeControllerTest 回归用例,覆盖携带 returnUrl、直接跳转 (ONLYJUMP_)与未携带 returnUrl 三种场景。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与验收标准
/api/pay/return/alipay后,jeepay-payment稳定产生一条告警:WARN [DefaultHandlerExceptionResolver] - Ignoring exception, response committed already: org.springframework.web.servlet.resource.NoResourceFoundException: No static resource api/pay/return/api/pay/return/alipay.订单状态与 302 跳转本身都正常,只是每次同步跳转都会多出这条异常告警。
ChannelNoticeController#doReturn是返回视图名的@Controller方法,先调用response.sendRedirect(...)再return null。响应已经提交,但 Spring MVC 认为请求未被处理,会按请求路径推导默认视图名并继续做资源解析,最终抛出
NoResourceFoundException;又因为响应已提交,异常被
DefaultHandlerExceptionResolver忽略并降级为 WARN 告警。onlyJump(订单号带ONLYJUMP_前缀的直跳分支)是同样的写法:response.sendRedirect(...)后由外层return null。jeepay-payment的同步跳转(doReturn/onlyJump)视图返回方式,并补回归测试。doNotify、渠道 SDK、签名算法、数据库与配置;AlipayBizController、ChannelUserIdController的重定向方法返回类型为void,不受该问题影响,本次不动。改动与兼容性
doReturn:把response.sendRedirect(url); return null;改为return "redirect:" + url;,由 Spring MVC 统一处理重定向(UrlBasedViewResolver的redirect:前缀会生成RedirectView,同样走response.sendRedirect(response.encodeRedirectURL(url)),对浏览器而言 302 与Location行为不变)。onlyJump:由void改为返回视图名,直接跳转时返回"redirect:" + url;订单不存在或未配置returnUrl时返回支付结果页视图。顺带修正了原代码里
this.toReturnPage(...)返回值被丢弃的问题——原先订单不存在时仍会继续执行并对空对象取getMchNo(),最终以空指针进入外层兜底分支。jeepay-payment的spring-boot-starter-test(test scope)依赖,用于运行 JUnit 5 / Mockito 回归测试。Location保持一致(302)。ChannelNoticeController的改动。验证
mvn -B -pl jeepay-payment -am install -DskipTests→ BUILD SUCCESSmvn -B -pl jeepay-payment -am test→ BUILD SUCCESSjava.version=17,编译参数release 17;仓库 CI 使用 JDK 17)。jeepay-payment/src/test/java/com/jeequan/jeepay/pay/ctrl/payorder/ChannelNoticeControllerTest.java,用 Mockito 打桩渠道通知服务、订单服务与商户配置,覆盖:携带returnUrl的同步跳转、ONLYJUMP_直跳订单号、未携带returnUrl三种场景(纯单元测试,不需要数据库、Redis 或真实支付渠道)。mvn -B -pl jeepay-payment test -Dtest=ChannelNoticeControllerTest):returnUrl的用例修复前后均为cashier/returnPage,用于保证原有行为不变。RedirectView与response.sendRedirect的等价行为以及单元测试断言。mvn -B test。合并前核对
dev;稳定热修复到master并关联回同步dev的计划 / PRCloses #125