question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameters defined via `@ClientHeaderParam` don't get applied to outbound request

See original GitHub issue

Hi everybody,

when using @RegisterClientHeaders along with DefaultClientHeadersFactoryImpl I expected the factory to behave like it’s described in the specification under Specifying Additional Client Headers

This interface has a single method and takes two read-only MultivaluedMap parameters … The method should return a MultivaluedMap that contains the headers to merge with this second map for the “final” map of headers to be sent to the outbound processing flow.

Now, when I check the respective code the second parameter clientOutgoingHeaders is actually not used (except for logging) and thus not merged to the output MultivaluedMap:

    @Override
    public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders,
                                                 MultivaluedMap<String, String> clientOutgoingHeaders) {

        if (LOG.isLoggable(Level.FINER)) {
            LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders});
        }
        MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>();
        Optional<String> propagateHeaderString = getHeadersProperty();
        if (propagateHeaderString.isPresent()) {
            Arrays.stream(propagateHeaderString.get().split(","))
                  .forEach( header -> {
                      if (incomingHeaders.containsKey(header)) {
                          propagatedHeaders.put(header, incomingHeaders.get(header));
                      }
                  });
        }
        if (LOG.isLoggable(Level.FINER)) {
            LOG.exiting(CLASS_NAME, "update", propagatedHeaders);
        }
        return propagatedHeaders;
    }

Thus, none of the header-values configured i.e. via @ClientHeaderParam get merged to the outbound request.

Is this behavior of DefaultClientHeadersFactoryImpl intended (since one can register its own Factory it’s actually easy work around … but still is surprising)?

Regards

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
kenfinnigancommented, Sep 1, 2020

I actually just hit this myself and was going to raise an issue.

@andymc12 do you agree that nothing in the spec says it should behave this way?

Will look to provide a fix in the morning, as this should be done for 2.0 in MP 4.0

0reactions
kenfinnigancommented, Sep 3, 2020

I’ve actually just submitted a PR to RESTEasy to perform the merge if the DefaultClientHeadersFactoryImpl is used.

It’s definitely something we can look into post 2.0, we’d need to decide whether it makes sense to favor clientOutgoingHeaders or output of update().

Read more comments on GitHub >

github_iconTop Results From Across the Web

ClientHeaderParam (MicroProfile Rest Client API 1.2.1 API)
Used to specify an HTTP parameter that should be sent with the outbound request. ... header will be sent on each request for...
Read more >
Using the REST Client Reactive - Quarkus
If the GET request requires path parameters you can leverage the @PathParam("parameter-name") annotation instead of (or in addition to) the @QueryParam . Path ......
Read more >
Chapter 2. Developing JAX-RS Web Services
Only use APIs specific to JBoss if a use case does not support using Java EE APIs. ... parameter defined and get the...
Read more >
Home of Quarkus Cheat-Sheet - GitHub Pages
To add configuration to your application, Quarkus relies on MicroProfile Config spec. ... ConfigIgnore annotation can be used to ignore the injection of ......
Read more >
Chapter 52. MicroProfile Rest Client - JBoss.org
@Path("resource") public interface TestResourceIntf { @Path("test") @GET public String test(); } TestResourceIntf service = RestClientBuilder.newBuilder() .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found