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.

JAXRS contract on API with @HeaderParam("Content-Type") and @Consumes with multiple values cause feign client build fail

See original GitHub issue

Version : 11.0

API :

    @POST
    @Path("/{stream:.+}")
    @Consumes({"application/xlsx", "text/csv"})
    @Produces("application/json")
    List<Integer> sourceFile(
            @PathParam("stream") String stream,
            @QueryParam("delimiterChar") @DefaultValue(",") String delimiterChar,
            @HeaderParam("Content-Type") String contentType,
            @RequestBody(required = true, description = "Input file") InputStream file
    ) throws IOException;

Calling API with :

myCtrl.sourceFile("stream", null, "text/csv", inputStream);

Causes the error :

java.lang.NullPointerException: null
	at feign.okhttp.OkHttpClient.toOkHttpRequest(OkHttpClient.java:64) ~[feign-okhttp-11.0.jar:na]
	at feign.okhttp.OkHttpClient.execute(OkHttpClient.java:168) ~[feign-okhttp-11.0.jar:na]
	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119) ~[feign-core-11.0.jar:na]
	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89) ~[feign-core-11.0.jar:na]
	at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) ~[feign-core-11.0.jar:na]
	at com.sun.proxy.$Proxy143.sourceFile(Unknown Source) ~[na:na]

Because at OkHttpClient:62 (mediaType = MediaType.parse(value);), value variable equals "application/xlsx, text/csv" instead of "text/csv". Method MediaType.parse(value) returns null as "application/xlsx, text/csv" is not a valid media type.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kdavisk6commented, May 2, 2020

Learn something every day…

0reactions
velocommented, May 2, 2020

Au contraire my good friend. Both support many values

Screen Shot 2020-05-03 at 00 50 48

The way encoders/decoders work on jax-rs allow they to handle multiple just fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Openfeign How to use @Headers annotation with different ...
I want to be able to do same thing but there is no Produces or consumes headers in feign client. There is only...
Read more >
Consuming REST API Using Feign - Nimbleways
Introduction · 1. first, create the request for the remote resource by specifying the URL, and the ( headers, body ) if needed....
Read more >
RESTEasy JAX-RS - JBoss.org
Used when the client is unable to use an Accept header to choose a representation (i.e. a browser). See Chapter 19, JAX-RS Content...
Read more >
Setting Request Headers Using Feign - Baeldung
Using the @Header annotation, we can easily configure a static request header. We can define this header value either statically or dynamically.
Read more >
AppDynamics_Cloud_Cogeng_...
1.40 javabeans-activation-framework-api 1.2.2 ... 1.58 jackson-jaxrs 2.13.2 ... Agreement or the failure by Confluent to exercise any right hereunder.
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