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

DefaultCxfMessageMapper.getBasePath creates a incorrect http path

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.17.2
    • 2.19.5, 2.20.2, 2.21.0
    • camel-cxf
    • None
    • Unknown

    Description

      in DefaultCxfMessageMapper.java:

          protected String getBasePath(Exchange camelExchange) {
              String answer = camelExchange.getIn().getHeader(Exchange.HTTP_BASE_URI, String.class);
              if (answer == null) {
                  answer = camelExchange.getFromEndpoint().getEndpointUri();
              }        
              return answer;
          }
      

      camelExchange.getFromEndpoint().getEndpointUri()

      in 2.14 returns a valid http URL for the jetty endpoint...]

      meanwhile in 2.17 it return a camel url that includes the scheme and it breaks the semantics of this method. I had to change the method to:

          protected String getBasePath(Exchange camelExchange) {
              String answer = camelExchange.getIn().getHeader(Exchange.HTTP_BASE_URI, String.class);
      
              if (answer == null) {
                  Endpoint fromEndpoint = camelExchange.getFromEndpoint();
                  if (fromEndpoint instanceof HttpCommonEndpoint) {
                    try {
                      URI u = ((HttpCommonEndpoint) fromEndpoint). getHttpUri();
                      answer = new URI(u.getScheme(), u.getUserInfo(), u.getHost(), u.getPort(), u.getPath(),
                              null, null).toString();
                    } catch (URISyntaxException ex) {
                      throw new RuntimeException(ex);
                    }
                  } else {
                    return null;
                  }
              }
      
              return answer;
          }
      

      I am not sure this is the best way to deal with this, but it works...

      Attachments

        1. CAMEL_10165_test_and_bugfix.patch
          3 kB
          Krzysztof Mackowiak

        Activity

          People

            davsclaus Claus Ibsen
            zolyfarkas Zoltan Farkas
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: