From f38ddedea3a7998141ce7e4e1008c9c60d500481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Miller=20=28=E9=94=BA=E4=BF=8A=29?= Date: Fri, 8 May 2020 17:34:30 +0800 Subject: [PATCH] perf($VarAndVal): synchronize codes - WebRequestLogAspect.java --- .../universal/aspect/WebRequestLogAspect.java | 13 ++++++------- .../universal/aspect/WebRequestLogAspect.java | 13 ++++++------- .../universal/aspect/WebRequestLogAspect.java | 13 ++++++------- .../universal/aspect/WebRequestLogAspect.java | 13 ++++++------- .../universal/aspect/WebRequestLogAspect.java | 13 ++++++------- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/auth-center/src/main/java/com/jmsoftware/authcenter/universal/aspect/WebRequestLogAspect.java b/auth-center/src/main/java/com/jmsoftware/authcenter/universal/aspect/WebRequestLogAspect.java index ded4ca37..dcbdc365 100644 --- a/auth-center/src/main/java/com/jmsoftware/authcenter/universal/aspect/WebRequestLogAspect.java +++ b/auth-center/src/main/java/com/jmsoftware/authcenter/universal/aspect/WebRequestLogAspect.java @@ -7,6 +7,7 @@ import com.jmsoftware.common.util.RequestUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; @@ -14,8 +15,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; - /** *

RequestLogAspect

*

Description:

@@ -61,9 +60,9 @@ public void requestLogPointcut() { */ @Before("requestLogPointcut()") public void beforeHandleRequest(JoinPoint joinPoint) { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + val attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); assert attributes != null; - HttpServletRequest request = attributes.getRequest(); + val request = attributes.getRequest(); log.info("============ WEB REQUEST LOG START ============"); log.info("URL : {}", request.getRequestURL().toString()); log.info("HTTP Method : {}", request.getMethod()); @@ -84,9 +83,9 @@ public void beforeHandleRequest(JoinPoint joinPoint) { */ @Around("requestLogPointcut()") public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Object result = proceedingJoinPoint.proceed(); - long elapsedTime = System.currentTimeMillis() - startTime; + val startTime = System.currentTimeMillis(); + val result = proceedingJoinPoint.proceed(); + val elapsedTime = System.currentTimeMillis() - startTime; try { var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result)); if (formattedStringifiedJson.length() > 500) { diff --git a/exercise-mis/src/main/java/com/jmsoftware/exercisemis/universal/aspect/WebRequestLogAspect.java b/exercise-mis/src/main/java/com/jmsoftware/exercisemis/universal/aspect/WebRequestLogAspect.java index 8532c774..2a559b5c 100644 --- a/exercise-mis/src/main/java/com/jmsoftware/exercisemis/universal/aspect/WebRequestLogAspect.java +++ b/exercise-mis/src/main/java/com/jmsoftware/exercisemis/universal/aspect/WebRequestLogAspect.java @@ -7,6 +7,7 @@ import com.jmsoftware.common.util.RequestUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; @@ -14,8 +15,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; - /** *

RequestLogAspect

*

Description:

@@ -61,9 +60,9 @@ public void requestLogPointcut() { */ @Before("requestLogPointcut()") public void beforeHandleRequest(JoinPoint joinPoint) { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + val attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); assert attributes != null; - HttpServletRequest request = attributes.getRequest(); + val request = attributes.getRequest(); log.info("============ WEB REQUEST LOG START ============"); log.info("URL : {}", request.getRequestURL().toString()); log.info("HTTP Method : {}", request.getMethod()); @@ -84,9 +83,9 @@ public void beforeHandleRequest(JoinPoint joinPoint) { */ @Around("requestLogPointcut()") public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Object result = proceedingJoinPoint.proceed(); - long elapsedTime = System.currentTimeMillis() - startTime; + val startTime = System.currentTimeMillis(); + val result = proceedingJoinPoint.proceed(); + val elapsedTime = System.currentTimeMillis() - startTime; try { var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result)); if (formattedStringifiedJson.length() > 500) { diff --git a/muscle-mis/src/main/java/com/jmsoftware/musclemis/universal/aspect/WebRequestLogAspect.java b/muscle-mis/src/main/java/com/jmsoftware/musclemis/universal/aspect/WebRequestLogAspect.java index c790aa9a..1d9e1ae8 100644 --- a/muscle-mis/src/main/java/com/jmsoftware/musclemis/universal/aspect/WebRequestLogAspect.java +++ b/muscle-mis/src/main/java/com/jmsoftware/musclemis/universal/aspect/WebRequestLogAspect.java @@ -7,6 +7,7 @@ import com.jmsoftware.common.util.RequestUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; @@ -14,8 +15,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; - /** *

RequestLogAspect

*

Description:

@@ -61,9 +60,9 @@ public void requestLogPointcut() { */ @Before("requestLogPointcut()") public void beforeHandleRequest(JoinPoint joinPoint) { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + val attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); assert attributes != null; - HttpServletRequest request = attributes.getRequest(); + val request = attributes.getRequest(); log.info("============ WEB REQUEST LOG START ============"); log.info("URL : {}", request.getRequestURL().toString()); log.info("HTTP Method : {}", request.getMethod()); @@ -84,9 +83,9 @@ public void beforeHandleRequest(JoinPoint joinPoint) { */ @Around("requestLogPointcut()") public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Object result = proceedingJoinPoint.proceed(); - long elapsedTime = System.currentTimeMillis() - startTime; + val startTime = System.currentTimeMillis(); + val result = proceedingJoinPoint.proceed(); + val elapsedTime = System.currentTimeMillis() - startTime; try { var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result)); if (formattedStringifiedJson.length() > 500) { diff --git a/service-registry/src/main/java/com/jmsoftware/serviceregistry/universal/aspect/WebRequestLogAspect.java b/service-registry/src/main/java/com/jmsoftware/serviceregistry/universal/aspect/WebRequestLogAspect.java index 6b818d9c..f1880358 100644 --- a/service-registry/src/main/java/com/jmsoftware/serviceregistry/universal/aspect/WebRequestLogAspect.java +++ b/service-registry/src/main/java/com/jmsoftware/serviceregistry/universal/aspect/WebRequestLogAspect.java @@ -7,6 +7,7 @@ import com.jmsoftware.common.util.RequestUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; @@ -14,8 +15,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; - /** *

RequestLogAspect

*

Description:

@@ -61,9 +60,9 @@ public void requestLogPointcut() { */ @Before("requestLogPointcut()") public void beforeHandleRequest(JoinPoint joinPoint) { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + val attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); assert attributes != null; - HttpServletRequest request = attributes.getRequest(); + val request = attributes.getRequest(); log.info("============ WEB REQUEST LOG START ============"); log.info("URL : {}", request.getRequestURL().toString()); log.info("HTTP Method : {}", request.getMethod()); @@ -84,9 +83,9 @@ public void beforeHandleRequest(JoinPoint joinPoint) { */ @Around("requestLogPointcut()") public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Object result = proceedingJoinPoint.proceed(); - long elapsedTime = System.currentTimeMillis() - startTime; + val startTime = System.currentTimeMillis(); + val result = proceedingJoinPoint.proceed(); + val elapsedTime = System.currentTimeMillis() - startTime; try { var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result)); if (formattedStringifiedJson.length() > 500) { diff --git a/spring-boot-admin/src/main/java/com/jmsoftware/springbootadmin/universal/aspect/WebRequestLogAspect.java b/spring-boot-admin/src/main/java/com/jmsoftware/springbootadmin/universal/aspect/WebRequestLogAspect.java index e63157e5..96890344 100644 --- a/spring-boot-admin/src/main/java/com/jmsoftware/springbootadmin/universal/aspect/WebRequestLogAspect.java +++ b/spring-boot-admin/src/main/java/com/jmsoftware/springbootadmin/universal/aspect/WebRequestLogAspect.java @@ -7,6 +7,7 @@ import com.jmsoftware.common.util.RequestUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.*; @@ -14,8 +15,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; - /** *

RequestLogAspect

*

Description:

@@ -61,9 +60,9 @@ public void requestLogPointcut() { */ @Before("requestLogPointcut()") public void beforeHandleRequest(JoinPoint joinPoint) { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + val attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); assert attributes != null; - HttpServletRequest request = attributes.getRequest(); + val request = attributes.getRequest(); log.info("============ WEB REQUEST LOG START ============"); log.info("URL : {}", request.getRequestURL().toString()); log.info("HTTP Method : {}", request.getMethod()); @@ -84,9 +83,9 @@ public void beforeHandleRequest(JoinPoint joinPoint) { */ @Around("requestLogPointcut()") public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Object result = proceedingJoinPoint.proceed(); - long elapsedTime = System.currentTimeMillis() - startTime; + val startTime = System.currentTimeMillis(); + val result = proceedingJoinPoint.proceed(); + val elapsedTime = System.currentTimeMillis() - startTime; try { var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result)); if (formattedStringifiedJson.length() > 500) {