From 320f2724c3fbbbbb1b0086d34307dfd193e3219b Mon Sep 17 00:00:00 2001 From: yizzuide Date: Fri, 24 Apr 2020 16:53:25 +0800 Subject: [PATCH] fix(comet): Fixed request parameter has unreadable code problem. --- .../yizzuide/milkomeda/comet/core/CometRequestFilter.java | 3 +++ .../yizzuide/milkomeda/comet/core/CometResponseWrapper.java | 1 + .../src/main/java/com/github/yizzuide/milkomeda/ice/Ice.java | 2 ++ .../github/yizzuide/milkomeda/ice/IceTtrOverloadListener.java | 2 +- .../java/com/github/yizzuide/milkomeda/util/ReflectUtil.java | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometRequestFilter.java b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometRequestFilter.java index 5a1ba496..26a77eba 100644 --- a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometRequestFilter.java +++ b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometRequestFilter.java @@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.nio.charset.Charset; /** * CometRequestFilter @@ -29,6 +30,8 @@ public void init(FilterConfig filterConfig) { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + // 设置编码,防止Spring MVC注册Filter顺序问题导致乱码问题 + servletRequest.setCharacterEncoding(Charset.defaultCharset().toString()); ServletRequest requestWrapper = servletRequest; // 如果有Form表单数据则不读取body,交给SpringMVC框架处理(但@CometParam功能仍然有效) if (CollectionUtils.isEmpty(servletRequest.getParameterMap())) { diff --git a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometResponseWrapper.java b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometResponseWrapper.java index 96c71cb3..7c284fc2 100644 --- a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometResponseWrapper.java +++ b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/comet/core/CometResponseWrapper.java @@ -174,6 +174,7 @@ public void copyBodyToResponse() throws IOException { * Copy the cached body content to the response. * @param complete whether to set a corresponding content length * for the complete cached body content + * @throws IOException Socket IO exception */ protected void copyBodyToResponse(boolean complete) throws IOException { if (this.content.size() > 0) { diff --git a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/Ice.java b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/Ice.java index 53ac8d8f..ecd5c760 100644 --- a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/Ice.java +++ b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/Ice.java @@ -57,6 +57,7 @@ public interface Ice { * @param body 业务数据 * @param delay 延迟时间 * @param 业务数据类型 + * @return Job * @since 3.0.9 */ Job build(String id, String topic, T body, Duration delay); @@ -68,6 +69,7 @@ public interface Ice { * @param body 业务数据 * @param delay 延迟时间ms * @param 业务数据类型 + * @return Job * @since 3.0.9 */ Job build(String id, String topic, T body, long delay); diff --git a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/IceTtrOverloadListener.java b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/IceTtrOverloadListener.java index 2387ed96..5404cdfb 100644 --- a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/IceTtrOverloadListener.java +++ b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/ice/IceTtrOverloadListener.java @@ -9,7 +9,7 @@ * TTR重试超载监听器 * *
- *     通过配置 {@link IceProperties#isEnableJobTimerDistributed()} 配合Dead queue的使用有以下情况:
+ *     通过配置 `ice.enable-job-timer-distributed` 配合Dead queue的使用有以下情况:
  *     1. TTR重试超载监听器未添加或执行失败 + 未开启Dead queue:通过计算延迟因子继续重试,并有错误级别的日志打印
  *     2. TTR重试超载监听器未添加或执行失败 + 开启Dead queue:延迟任务进入Dead queue,原数据保留
  *     3. TTR重试超载监听器执行成功 + 未开启Dead queue:延迟任务和原数据都将被移除
diff --git a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/util/ReflectUtil.java b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/util/ReflectUtil.java
index 9dfd5ebf..321752b0 100644
--- a/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/util/ReflectUtil.java
+++ b/Milkomeda/src/main/java/com/github/yizzuide/milkomeda/util/ReflectUtil.java
@@ -126,6 +126,7 @@ public static String extractValue(JoinPoint joinPoint, String express) {
      * @param                包装对象类型
      * @throws IllegalAccessException       非法访问异常
      * @throws InvocationTargetException    方法调用异常
+     * @return 返回原有值
      */
     public static  Object invokeWithWrapperInject(Object target, Method method, List wrapperList, Class wrapperClazz, Function wrapperBody, BiConsumer wipeWrapperBody) throws IllegalAccessException, InvocationTargetException {
         // 没有参数