Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15363

jetty:....?matchOnUriPrefix in combination with rest: gives 404 or 405

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 2.24.0, 2.25.1, 3.4.1
    • None
    • camel-http-common
    • None
    • Unknown

    Description

      Presence of a "rest:" route that uses URL templates breaks a regular "jetty:" route that has "?matchOnUriPrefix=true&httpMethodRestrict=GET" attributes.

      Looks like CAMEL-11951 wasn't fixed.

      How to check:

      // this magic route doesn't work if all of the subsequent routes are present
      // interestingly, it catches anything starting with "res" ignoring the "/" after it
      from("jetty:http://0.0.0.0:8686/res/?matchOnUriPrefix=true&httpMethodRestrict=GET")
              .setBody().mvel("'RESOURCE GET path: ' + exchange.in.request.requestURI");
      
      // a catch all route that needs to be here always
      from("jetty:http://0.0.0.0:8686?matchOnUriPrefix=true&httpMethodRestrict=GET")
              .setBody().mvel("'ROOT GET path: ' + exchange.in.request.requestURI");
      
      // a catch all POST route
      // if you comment out this, you will get 404 for the "magic" route instead of 405
      from("jetty:http://0.0.0.0:8686?matchOnUriPrefix=true&httpMethodRestrict=POST")
              .setBody(constant("ROOT POST"));
      
      // if this route is commented out, the magic route starts woking, otherwise the magic route produces 405
      from("rest:get:/test/{test}")
            .setBody(simple("SOPHISTICATED REST. Header: ${header.test}"));
      
      // this rest service doesn't break the magic route.
      from("rest:get:/dumb")
              .setBody(simple("DUMB REST"));
      
      
      Tested with Camel 2.25.1 and 3.4.1, but more interested in fixing ver. 2.x 

      Run this and see the 405 error for any request starting from "/res".

      Comment out "rest:get:/test/{test}" and see the "/res/ route starting working.

      (As per requirements, the first three routes in this example have to stay first as in the big application other routes are added dynamically.)

      Attached is a java file with the main method to test.

      Attachments

        1. Main.java
          3 kB
          Fyodor Kravchenko

        Activity

          People

            Unassigned Unassigned
            fedd Fyodor Kravchenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: