-
Notifications
You must be signed in to change notification settings - Fork 1.1k
HttpRequestHandlingEndpointSupport throws IllegalStateException when duplicate cookie names are in a request #3641
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
Comments
Thank you for bringing this and for the fix. I agree that is kinda regression, but I wonder what HTTP spec says on the matter instead of that our previous blind “duplicates were ignored" and current illegal state… |
See here: https://datatracker.ietf.org/doc/html/rfc6265#section-4.2
So, sounds like we have to accept all of them. In other words it must be a |
Just to confirm my original assumption.
I see also there is a NOTE: |
@artembilan I like the MultiValueMap approach - This would allow all cookies in the request to be available to the evaluation context and it does seem more in line with the HTTP spec as you mentioned. |
Right. But as you see we cannot do that in the current point version: it would be too breaking change for end-users who rely on a single value map at the moment. |
Yes, that makes sense - The value would be a list of cookies and not a single cookie. toSingleValueMap() sounds like a good approach for now |
Fixes #3641 When a duplicate cookie name appears in a request, an `IllegalStateException` is thrown. The default `Collectors.toMap()` does not allow a duplicated keys. * Handle `servletRequest.getCookies()` as a `MultiValueMap` * Call `toSingleValueMap()` for the evaluation context variable to restore previous behavior. The next major version must expose the `MultiValueMap` as is to give access to all cookies from end-user expressions * Rework some HTTP tests to JUnit 5 **Cherry-pick to `5.4.x` & `5.3.x`**
Fixes #3641 When a duplicate cookie name appears in a request, an `IllegalStateException` is thrown. The default `Collectors.toMap()` does not allow a duplicated keys. * Handle `servletRequest.getCookies()` as a `MultiValueMap` * Call `toSingleValueMap()` for the evaluation context variable to restore previous behavior. The next major version must expose the `MultiValueMap` as is to give access to all cookies from end-user expressions * Rework some HTTP tests to JUnit 5 **Cherry-pick to `5.4.x` & `5.3.x`**
And the fix has been cherry-picked to |
Hi @artembilan |
Have just scheduled it for the next week: https://github.com/spring-projects/spring-integration/milestone/79 |
Thank you so much! |
In what version(s) of Spring Integration are you seeing this issue?
5.2.0.RELEASE and later, NOT in versions 4.x
Describe the bug
When a duplicate cookie name appears in a request, an IllegalStateException is thrown. Previously the last cookie was put in the "evaluationContext" cookies map, and duplicates were ignored. There was an update made to use Java steams instead of a for loop in the HttpRequestHandlingEndpointSupport#prepareEvaluationContext() method, however Collectors.toMap(...) was not used with a merge function, therefore it throws the IllegalStateException when you try to map two keys.
To Reproduce
Send an HTTP request with duplicate cookies
Expected behavior
I expect the request to ignore the duplicates or to throw an exception with a clear and concise message explaining that duplicate cookies are not allowed. Preferably the request would be handled gracefully, like it was in previous versions, and simply use the last cookie in the request.getCookies() array.
Sample
The text was updated successfully, but these errors were encountered: