public Object[] parseParameterFor(String resource, T request, Predicate<GatewayFlowRule> rulePredicate) {
        if (StringUtil.isEmpty(resource) || request == null || rulePredicate == null) {
            return new Object[0];
        }
        Set<GatewayFlowRule> gatewayRules = new HashSet<>();
        Set<Boolean> predSet = new HashSet<>();
        boolean hasNonParamRule = false;
        for (GatewayFlowRule rule : GatewayRuleManager.getRulesForResource(resource)) {
            if (rule.getParamItem() != null) {
                gatewayRules.add(rule);
                predSet.add(rulePredicate.test(rule));
            } else {
                hasNonParamRule = true;
            }
        }
        if (!hasNonParamRule && gatewayRules.isEmpty()) {
            return new Object[0];
        }
        if (predSet.size() > 1 || predSet.contains(false)) {
            return new Object[0];
        }
        int size = hasNonParamRule ? gatewayRules.size() + 1 : gatewayRules.size();
        Object[] arr = new Object[size];
        for (GatewayFlowRule rule : gatewayRules) {
            GatewayParamFlowItem paramItem = rule.getParamItem();
            int idx = paramItem.getIndex();
            String param = parseInternal(paramItem, request);
            arr[idx] = param;
        }
        if (hasNonParamRule) {
            arr[size - 1] = SentinelGatewayConstants.GATEWAY_DEFAULT_PARAM;
        }
        return arr;
    }
@Test
    public void testParseParametersWithEmptyItemPattern() {
        RequestItemParser<Object> itemParser = mock(RequestItemParser.class);
        GatewayParamParser<Object> paramParser = new GatewayParamParser<>(itemParser);
        // Create a fake request.
        Object request = new Object();
        // Prepare gateway rules.
        Set<GatewayFlowRule> rules = new HashSet<>();
        final String routeId = "my_test_route_DS(*H";
        final String headerName = "X-Sentinel-Flag";
        GatewayFlowRule routeRule1 = new GatewayFlowRule(routeId)
            .setCount(10)
            .setIntervalSec(2)
            .setParamItem(new GatewayParamFlowItem()
                .setParseStrategy(SentinelGatewayConstants.PARAM_PARSE_STRATEGY_HEADER)
                .setFieldName(headerName)
                .setPattern("")
                .setMatchStrategy(SentinelGatewayConstants.PARAM_MATCH_STRATEGY_EXACT)
            );
        rules.add(routeRule1);
        GatewayRuleManager.loadRules(rules);

        mockSingleHeader(itemParser, headerName, "Sent1nel");
        Object[] params = paramParser.parseParameterFor(routeId, request, routeIdPredicate);
        assertThat(params.length).isEqualTo(1);
        // Empty pattern should not take effect.
        assertThat(params[routeRule1.getParamItem().getIndex()]).isEqualTo("Sent1nel");
    }