huwenming-saw opened a new issue #2291:
URL: https://github.com/apache/incubator-shenyu/issues/2291


   ### Question
   
   1. run `admin` dashboard enabled `springCloud` and `sentinel` plugin (2.4.1)
   2. run `bootstrap` (2.4.1)
   3. run a client which throws a error immediately (2.4.1)
   4. my sentinel rule 
   
![image](https://user-images.githubusercontent.com/50895750/139776282-755f298a-c55c-49b7-b977-78205c78e939.png)
   5. response 
   ```json
   {
     "timestamp": "2021-11-02T02:12:06.970+0000",
     "status": 500,
     "error": "Internal Server Error",
     "message": "服务暂不可用!",
     "path": "/springcloud/nlog/save"
   }
   ```
   6. in the source code 
   ```java
       protected Mono<Void> doExecute(final ServerWebExchange exchange, final 
ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) {
           final ShenyuContext shenyuContext = 
exchange.getAttribute(Constants.CONTEXT);
           assert shenyuContext != null;
           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 -> {
               HttpStatus status = 
exchange.getResponse().getStatusCode();//debug step here , status = 200, so it 
didn't throw a error and then sentinel mistakenly assumed that no error has 
occurred
               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));
       }
   ```
   7. Maybe you need to reuse 
`Constants.CLIENT_RESPONSE_RESULT_TYPE`:`ResultEnum` in the source code 
`org.apache.shenyu.plugin.httpclient.WebClientPlugin#doNext`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to