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.

Can't use setHeader(Header) because ambigous method call

See original GitHub issue

Header is both a Header and a Map so this won’t work:

Header header = new DefaultHeader();

String payloadWithoutPartner1 = Jwts.builder()
         .setClaims(claims)
         .signWith(SignatureAlgorithm.HS256, key)
         .setHeader(header)
         .compact();

Ambiguous method call. Both setHeader (Header) in JwtBuilder and setHeader(Map<String, Object>) in JwtBuilder match

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:11
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
kleewhocommented, Oct 3, 2016

@lhazlewood using Jwts.header() doesn’t change anything. Standard technique or not compiler won’t know which overload version to use, cause both are applicable. This is the simplest thing you can paste and check for yourself:

@Test
    public void whatever() {
        Header header = Jwts.header();

        String payloadWithoutPartner1 = Jwts.builder()
                .setHeader(header)
                .compact();
    }
2reactions
robrezcommented, Apr 10, 2017

Casting to map .setHeader((Map<String, Object>) header) works

Like the last entry stated, I used setHeaderParam, instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CORS Policy won't work, because all response headers are ...
I trie to get a response from my POST Method in my Servlet java class. I trie to set all headers ...
Read more >
"The method X is ambiguous for the type Y" Java ambiguous ...
Suppose we have a java program like below. Above program compiles perfectly and when we run it, it prints “String”.
Read more >
tornado.web — RequestHandler and Application classes
Clears an outgoing header, undoing a previous set_header call. Note that this method does not apply to multi-valued headers set by add_header ....
Read more >
Spring Integration Reference Manual
Also, in the second example above, you can see how to set any user-defined header with setHeader . Finally, there are set methods...
Read more >
HttpRequest.getHeader('Content-Length')) returns null
Content-Length is a header that's automatically calculated on your behalf. You can set it, but it'll be ignored (because the Body attribute ...
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