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

Claus Ibsen updated CAMEL-27728:
--------------------------------
    Fix Version/s: 4.25.0
                       (was: 4.24.0)

> camel-stitch: disposes shared HttpClient, fails on duplicate headers, 
> keyNames parsing
> --------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27728
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27728
>             Project: Camel
>          Issue Type: Bug
>            Reporter: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-stitch for CAMEL-23832 
> (commit 
> https://github.com/apache/camel/commit/d7981ec106bbcc00a93375168223618689f2ee56).
> These are separate problems of the component; the descriptions commit only 
> documents the current behavior.
> h4. 1. Stopping an endpoint disposes a user supplied HttpClient or 
> ConnectionProvider
> {{StitchEndpoint.doStop()}} calls {{StitchClient.close()}} whenever the 
> {{stitchClient}} option is not set, also when the client was built from the 
> {{httpClient}} or {{connectionProvider}} option. {{StitchClientImpl.close()}} 
> then calls 
> {{httpClient.configuration().connectionProvider().disposeLater().block()}}, 
> which disposes the connection pool of the user's HttpClient or the user's 
> ConnectionProvider. Any other endpoint or code that shares that bean can no 
> longer send requests after one endpoint stops.
> Only dispose the connection provider when the endpoint created the HttpClient 
> and the ConnectionProvider itself.
> h4. 2. Restarting an endpoint reuses the closed client
> {{StitchEndpoint.doStart()}} creates the client only when the 
> {{stitchClient}} field is null, and {{doStop()}} closes it without setting 
> the field back to null. After a stop and start (for example a route restart) 
> the producer uses a client whose connection provider was disposed.
> Set the field to null in {{doStop()}} after closing a client that the 
> endpoint created.
> h4. 3. Duplicate response headers fail the exchange
> {{StitchClientImpl.getHeaders()}} collects the response headers with 
> {{Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)}} without a merge 
> function. When the response has the same header name more than once (for 
> example two {{Set-Cookie}} headers), it throws {{IllegalStateException: 
> Duplicate key}} and the exchange fails, although Stitch accepted the batch.
> Merge the values of a repeated header (for example into a list, or with 
> {{HttpHeaders.getAll}}).
> h4. 4. Key names of the option and header are not trimmed
> {{StitchProducerOperations.getKeyNames()}} splits the {{keyNames}} option or 
> the {{CamelStitchKeyNames}} header on {{,}} without trimming, so 
> {{keyNames=id, name}} sends the key name {{" name"}}. The {{key_names}} 
> String of a Map body is trimmed and empty names are dropped 
> ({{StitchRequestBody.getKeyNames()}}).
> Trim the names and drop empty ones, as for the Map body.
> h4. 5. CamelStitchKeyNames header is documented as Collection<String> but 
> read as a String
> {{StitchConstants.KEY_NAMES}} has {{javaType = "Collection<String>"}}, but 
> {{StitchProducerOperations.getKeyNames()}} reads it with 
> {{message.getHeader(KEY_NAMES, String.class)}}. A {{List}} value is converted 
> with {{toString()}} to {{"[a, b]"}}, which gives the key names {{"[a"}} and 
> {{" b]"}}.
> Accept a Collection (and a String) in the header, or change the javaType to 
> String.
> h4. 6. token is required when stitchClient is set
> {{StitchComponent.validateConfigurations()}} fails the endpoint creation when 
> {{token}} is empty, also when the {{stitchClient}} option is set, which does 
> not use the token. The metadata marks {{token}} as required.
> Skip the check when {{stitchClient}} is set.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to