Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAXRS contract on API with @HeaderParam and @QueryParam cause feign client build fail #891

Closed
bwangfdu opened this issue Feb 1, 2019 · 1 comment

Comments

@bwangfdu
Copy link

bwangfdu commented Feb 1, 2019

Version 10.1.0
API definition:

@GET
    @Path("/orders/{externalOrderId}")
    @Produces({ "application/vnd.mycompany.application.order.v1+json", "application/vnd.mycompany.application.order+json", "application/vnd.mycompany.application.order.v2+json" })
    @ApiOperation(value = "Orders_GetOrderDetail", tags={  })
    @ApiResponses(value = { 
        @ApiResponse(code = 200, message = "OK", response = Order.class),
        @ApiResponse(code = 400, message = "Bad request", response = BadRequestResponseModel.class),
        @ApiResponse(code = 404, message = "Not Found", response = NotFoundResponseModel.class),
        @ApiResponse(code = 412, message = "Precondition Failed", response = PreconditionFailedModel.class),
        @ApiResponse(code = 500, message = "Internal Server Error", response = InternalErrorResponseModel.class) })
    public Order ordersGetOrderDetail(@PathParam("externalOrderId") String externalOrderId, @HeaderParam("Accept") String accept, @HeaderParam("Authorization") String authorization);

Error stack trace:

Caused by: java.lang.UnsupportedOperationException: null
	at java.base/java.util.Collections$UnmodifiableCollection.add(Collections.java:1058)
	at feign.jaxrs.JAXRSContract.addTemplatedParam(JAXRSContract.java:186)
	at feign.jaxrs.JAXRSContract.processAnnotationsOnParameter(JAXRSContract.java:165)
	at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:110)
	at feign.jaxrs.JAXRSContract.parseAndValidateMetadata(JAXRSContract.java:44)
	at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:66)
	at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:154)
	at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:52)
	at feign.Feign$Builder.target(Feign.java:251)
	... 42 common frames omitted

This is caused by the Line 186 of JAXRSContract.java which trying to add an element into the template's headers or queries which become unmodified in 10.1.0, the previous version are not affected.
Can modify in JAXRSContract.java to make a new Collection instance and add new value then return it, wrapping unmodified if want to make accordance with feign-core.

@bwangfdu
Copy link
Author

bwangfdu commented Feb 7, 2019

This is duplicate with #896

@bwangfdu bwangfdu closed this as completed Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant