@Override
    protected Mono<Void> doExecute(final ServerWebExchange exchange, final ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) {
        String handle = rule.getHandle();
        RewriteHandle rewriteHandle = RewritePluginDataHandler.CACHED_HANDLE.get().obtainHandle(CacheKeyUtils.INST.getKey(rule));
        if (Objects.isNull(rewriteHandle)) {
            LOG.error("uri rewrite rule can not configuration：{}", handle);
            return chain.execute(exchange);
        }
        String rewriteUri = this.getRawPath(exchange);
        // the default percentage compatible with older versions is 100
        final Integer percentage = Optional.ofNullable(rewriteHandle.getPercentage()).orElse(100);
        if (StringUtils.isNoneBlank(rewriteHandle.getRegex(), rewriteHandle.getReplace())
                && ThreadLocalRandom.current().nextInt(100) < percentage) {
            rewriteUri = rewriteHandle.getReplace().contains("{")
                    ? PathMatchUtils.replaceAll(rewriteHandle.getReplace(), rewriteHandle.getRegex().substring(rewriteHandle.getRegex().indexOf("{")),
                            rewriteUri.substring(rewriteHandle.getRegex().indexOf("{") + 1))
                    : rewriteUri.replaceAll(rewriteHandle.getRegex(), rewriteHandle.getReplace());
            Map<String, Object> attributes = exchange.getAttributes();
            if (Optional.ofNullable(rewriteHandle.getRewriteMetaData()).orElse(false)) {
                // when the rewritten uri crosses plugins, this is necessary
                final String contextPath = Optional.ofNullable((String) exchange.getAttribute(Constants.REWRITE_CONTEXT_PATH))
                        .orElseGet(() -> exchange.getAttribute(Constants.CONTEXT_PATH));
                MetaData metaData = MetaDataCache.getInstance().obtain(contextPath + rewriteUri);
                Optional.ofNullable(exchange.getAttribute(Constants.META_DATA))
                        .ifPresent(metadata -> attributes.put(Constants.OLD_CONTEXT_PATH_META_DATA, metadata));
                if (Objects.nonNull(metaData)) {
                    attributes.put(Constants.META_DATA, metaData);
                }
                ShenyuContext context = exchange.getAttribute(Constants.CONTEXT);
                assert context != null;
                if (Objects.nonNull(metaData) && Boolean.TRUE.equals(metaData.getEnabled())) {
                    context.setRpcType(metaData.getRpcType());
                } else {
                    context.setRpcType(RpcTypeEnum.HTTP.getName());
                }
            }
            attributes.put(Constants.REWRITE_URI, rewriteUri);
        }
        return chain.execute(exchange);
    }
@Test
    public void testRewritePlugin() {
        RuleData data = new RuleData();
        data.setHandle("{\"regex\":\"\",\"replace\":\"\"}");
        RewriteHandle rewriteHandle = GsonUtils.getGson().fromJson(data.getHandle(), RewriteHandle.class);
        RewritePluginDataHandler.CACHED_HANDLE.get().cachedHandle(CacheKeyUtils.INST.getKey(data), rewriteHandle);
        when(chain.execute(exchange)).thenReturn(Mono.empty());
        SelectorData selectorData = mock(SelectorData.class);
        StepVerifier.create(rewritePlugin.doExecute(exchange, chain, selectorData, data)).expectSubscription().verifyComplete();
        assertTrue(StringUtils.isBlank((String) exchange.getAttributes().get(Constants.REWRITE_URI)));
    }