@Override
    public List<Object> handle(String targetName, List<Object> instances, RequestData requestData) {
        if (requestData == null) {
            return super.handle(targetName, instances, null);
        }
        if (!shouldHandle(instances)) {
            return instances;
        }
        List<Object> result = routerConfig.isUseRequestRouter()
                ? getTargetInstancesByRequest(targetName, instances, requestData.getTag())
                : getTargetInstancesByRules(targetName, instances, requestData.getPath(), requestData.getTag());
        return super.handle(targetName, result, requestData);
    }
@Test
    public void testGetTargetInstancesByRequestWithTags() {
        config.setUseRequestRouter(true);
        config.setRequestTags(Arrays.asList("foo", "bar", "version"));
        List<Object> instances = new ArrayList<>();
        ServiceInstance instance1 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.0",
                Collections.singletonMap("bar", "bar1"));
        instances.add(instance1);
        ServiceInstance instance2 = TestDefaultServiceInstance
                .getTestDefaultServiceInstance("1.0.1", Collections.singletonMap("foo", "bar2"));
        instances.add(instance2);
        ServiceInstance instance3 = TestDefaultServiceInstance.getTestDefaultServiceInstance("1.0.1");
        instances.add(instance3);
        Map<String, List<String>> header = new HashMap<>();

        // Match the foo:bar2 instance
        header.clear();
        header.put("foo", Collections.singletonList("bar2"));
        header.put("foo1", Collections.singletonList("bar2"));
        List<Object> targetInstances = flowRouteHandler.handle("foo", instances, new RequestData(header, null, null));
        Assert.assertEquals(1, targetInstances.size());
        Assert.assertEquals(instance2, targetInstances.get(0));

        // The instance that matches version 1.0.0 is matched
        header.clear();
        header.put("version", Collections.singletonList("1.0.0"));
        targetInstances = flowRouteHandler.handle("foo", instances, new RequestData(header, null, null));
        Assert.assertEquals(1, targetInstances.size());
        Assert.assertEquals(instance1, targetInstances.get(0));
    }