@Override
    public void connect(HttpConsumer consumer) {
        log.debug("Connecting consumer: {}", consumer);
        String endpointUri = consumer.getEndpoint().getEndpointUri();
        if (consumers.containsKey(endpointUri)) {
            throw new IllegalStateException("Duplicate request path for " + endpointUri);
        }
        consumers.put(endpointUri, consumer);
        RestConsumerContextPathMatcher.register(consumer.getPath());
    }
@Test
    public void testDuplicatedServletPath() throws URISyntaxException {
        CamelServlet camelServlet = new CamelServlet();

        HttpCommonEndpoint httpCommonEndpoint = new HttpCommonEndpoint() {

            @Override
            public Producer createProducer() {
                return null;
            }

            @Override
            public Consumer createConsumer(Processor processor) {
                return null;
            }
        };

        DefaultCamelContext dc = new DefaultCamelContext();

        httpCommonEndpoint.setEndpointUriIfNotSpecified("rest:post://camel.apache.org");
        httpCommonEndpoint.setHttpUri(URISupport.createRemainingURI(
                new URI(UnsafeUriCharactersEncoder.encodeHttpURI("servlet:/camel.apache.org?httpMethodRestrict=GET")),
                new LinkedHashMap<>()));
        httpCommonEndpoint.setCamelContext(dc);

        HttpConsumer httpConsumer1 = new HttpConsumer(httpCommonEndpoint, null);
        HttpConsumer httpConsumer2 = new HttpConsumer(httpCommonEndpoint, null);

        camelServlet.connect(httpConsumer1);
        IllegalStateException illegalStateException
                = assertThrows(IllegalStateException.class, () -> camelServlet.connect(httpConsumer2));
        assertEquals("Duplicate request path for rest:post://camel.apache.org",
                illegalStateException.getMessage());
    }