camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zoltan Farkas (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-10165) DefaultCxfMessageMapper.getBasePath creates a incorrect http path
Date Thu, 21 Jul 2016 16:46:20 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-10165?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Zoltan Farkas updated CAMEL-10165:
----------------------------------
    Description: 
in DefaultCxfMessageMapper.java:

{code}
    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;
    }
{code}

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:

{code}
    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;
    }
{code}

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








  was:
in DefaultCxfMessageMapper.java:

{code}
    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;
    }
{code}

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:

{code}
    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) {
              answer = ((HttpCommonEndpoint) fromEndpoint).getHttpUri().toString();
            } else {
              return null;
            }
        }

        return answer;
    }
{code}

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









> DefaultCxfMessageMapper.getBasePath creates a incorrect http path
> -----------------------------------------------------------------
>
>                 Key: CAMEL-10165
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10165
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxf
>    Affects Versions: 2.17.2
>            Reporter: Zoltan Farkas
>
> in DefaultCxfMessageMapper.java:
> {code}
>     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;
>     }
> {code}
> 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:
> {code}
>     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;
>     }
> {code}
> I am not sure this is the best way to deal with this, but it works...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message