This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 8c1cacb  [ISSUE 2743] Fix sentinel Plugin-exception number is not 
effective (#2772)
8c1cacb is described below

commit 8c1cacb775f848c7f20a9842a2487d56a897b3c2
Author: SaberSola <[email protected]>
AuthorDate: Fri Jan 14 23:21:10 2022 +0800

    [ISSUE 2743] Fix sentinel Plugin-exception number is not effective (#2772)
    
    * fix ShenyuClientRegisterService buildHandle method
    
    * fix  init ratelimiter redis script thread safe
    
    * add accessToken when use http register center
    
    * add accessToken when use http register center
    
    * add accessToken when use http register center
    
    * Long polling with admin token
    
    * merge master
    
    * remove white path
    
    * fix config
    
    * fix sentinel triger degrade
    
    Co-authored-by: zhanglei06469 <[email protected]>
---
 .../java/org/apache/shenyu/plugin/httpclient/WebClientPlugin.java    | 1 +
 .../main/java/org/apache/shenyu/plugin/sentinel/SentinelPlugin.java  | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/WebClientPlugin.java
 
b/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/WebClientPlugin.java
index 24e8fc3..4aeb1df 100644
--- 
a/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/WebClientPlugin.java
+++ 
b/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/WebClientPlugin.java
@@ -130,6 +130,7 @@ public class WebClientPlugin implements ShenyuPlugin {
         } else {
             
exchange.getAttributes().put(Constants.CLIENT_RESPONSE_RESULT_TYPE, 
ResultEnum.ERROR.getName());
         }
+        exchange.getResponse().setStatusCode(res.statusCode());
         exchange.getAttributes().put(Constants.CLIENT_RESPONSE_ATTR, res);
         return chain.execute(exchange);
     }
diff --git 
a/shenyu-plugin/shenyu-plugin-sentinel/src/main/java/org/apache/shenyu/plugin/sentinel/SentinelPlugin.java
 
b/shenyu-plugin/shenyu-plugin-sentinel/src/main/java/org/apache/shenyu/plugin/sentinel/SentinelPlugin.java
index bdc2888..edfb8db 100644
--- 
a/shenyu-plugin/shenyu-plugin-sentinel/src/main/java/org/apache/shenyu/plugin/sentinel/SentinelPlugin.java
+++ 
b/shenyu-plugin/shenyu-plugin-sentinel/src/main/java/org/apache/shenyu/plugin/sentinel/SentinelPlugin.java
@@ -53,13 +53,14 @@ public class SentinelPlugin extends AbstractShenyuPlugin {
         String resourceName = CacheKeyUtils.INST.getKey(rule);
         SentinelHandle sentinelHandle = 
GsonUtils.getInstance().fromJson(rule.getHandle(), SentinelHandle.class);
         sentinelHandle.checkData(sentinelHandle);
-        return chain.execute(exchange).transform(new 
SentinelReactorTransformer<>(resourceName)).doOnSuccess(v -> {
+        return chain.execute(exchange).doOnSuccess(v -> {
             HttpStatus status = exchange.getResponse().getStatusCode();
             if (status == null || !status.is2xxSuccessful()) {
                 exchange.getResponse().setStatusCode(null);
                 throw new SentinelFallbackException(status == null ? 
HttpStatus.INTERNAL_SERVER_ERROR : status);
             }
-        }).onErrorResume(throwable -> fallbackHandler.fallback(exchange, 
UriUtils.createUri(sentinelHandle.getFallbackUri()), throwable));
+        }).transform(new 
SentinelReactorTransformer<>(resourceName)).onErrorResume(throwable ->
+                fallbackHandler.fallback(exchange, 
UriUtils.createUri(sentinelHandle.getFallbackUri()), throwable));
     }
 
     @Override

Reply via email to