Skip to content

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

@pdesoyres

Description

@pdesoyres

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feedback providedFeedback has been provided to the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions