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

RestDefinition relies on Class.getCanonicalName instead of Class.getName for in/out types

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.0
    • Component/s: camel-core-engine
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      RestDefinition relies on Class.getCanonicalName instead of Class.getName for in/out types.

      This work as long as the type is not an inner class getCanonicalName does not return a name that can be used to load a class.

      As example

      package my.example;
      
      public class MyRoutes extends org.apache.camel.builder.RouteBuilder {
          @Override
          public void configure() throws Exception {
              rest()
                  .post("/order")
                      .type(MyOrder.class)
                      .consumes("application/json")
                      .produces("application/json")
                      .bindingMode(RestBindingMode.json)
                      .route()
                          .log("${body}");
          }
      
          public static class MyOrder {
              public String id;
          }
      }
      

      Then camel would set my.example.MyRoutes.MyOrder as in type but that's wrong and the subsequent attemp to load the class by name, will fail as it should be my.example.MyRoutes$MyOrder (which is what Class.getName would return).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lb Luca Burgazzoli
                Reporter:
                lb Luca Burgazzoli
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: