This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
new a3eb361d3 Return should not be used in anonymous functions, it will
throw ControlThrowable and cause logic processing errors (#3732)
a3eb361d3 is described below
commit a3eb361d3666262068e4116c0bfd287d2a3d02ac
Author: 成彬彬 <[email protected]>
AuthorDate: Fri Oct 28 09:52:15 2022 +0800
Return should not be used in anonymous functions, it will throw
ControlThrowable and cause logic processing errors (#3732)
---
.../linkis/server/restful/SpringRestfulCatchAOP.scala | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git
a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/restful/SpringRestfulCatchAOP.scala
b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/restful/SpringRestfulCatchAOP.scala
index 63d2f7997..3c03417b1 100644
---
a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/restful/SpringRestfulCatchAOP.scala
+++
b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/restful/SpringRestfulCatchAOP.scala
@@ -40,7 +40,10 @@ class SpringRestfulCatchAOP extends Logging {
@Around("springRestfulResponseCatch()")
def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = {
val resp: Message = catchIt {
- return proceedingJoinPoint.proceed()
+ proceedingJoinPoint.proceed() match {
+ case message: Message => message
+ case _ => Message.error("Failed to dealResponse get null message")
+ }
}
// convert http status code
getCurrentHttpResponse.setStatus(Message.messageToHttpStatus(resp))
@@ -49,11 +52,12 @@ class SpringRestfulCatchAOP extends Logging {
def getCurrentHttpResponse: HttpServletResponse = {
val requestAttributes = RequestContextHolder.getRequestAttributes
- if (requestAttributes.isInstanceOf[ServletRequestAttributes]) {
- val response =
requestAttributes.asInstanceOf[ServletRequestAttributes].getResponse
- return response
+ requestAttributes match {
+ case attributes: ServletRequestAttributes =>
+ val response = attributes.getResponse
+ response
+ case _ => null
}
- null
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]