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
MultiValueMapAdapter.getFirst fails with IndexOutOfBoundsException in case of empty List #25140
Comments
The common scenario is that such a list either contains one or more values or isn't set at all (in case of no value associated with a key). That said, point taken, we should align this with the existing |
OK, but the adapter is used in method: and there is accepted any Map<K, List> map |
Good point, it can be constructed with any target map content, including empty list values there. Also, an Thanks for raising this, in any case! I've marked it for a fix in the upcoming 5.2.7 and 5.1.16 releases. |
@jhoeller could I give it a go? I have also prepared unit tests. |
@midumitrescu I got a local commit for 5.2.x staged along with a few others, using the same code that we have in If you got unit tests for |
@midumitrescu I see that your commit uses To be clear about the unit tests, we don't have any at the moment. We'd benefit from complete unit tests for |
@jhoeller Sorry, I did not see your message in time. I'll close my PR. To not forget,
also calls
Producing basically the same ArrayIndexOutOfBoundsException. By not wanting to duplicate the behavior I came to
Just let me know when to add the unit tests. However, I can gladly also complete them with some meaningful ones. |
That's a good catch indeed, my 5.2.x commit has this aligned with the As for the unit tests, |
@jhoeller I think I needed a bit of time to understand what you mean by aligning implementations. Are you meaning
Or is the MultiValueMapAdapter really needed? |
At this point it's just about coding the same methods the same way in both implementations. You got a point though, except for |
Understood. I would be interested in giving a hand there, if needed. If not, I will attend the unit tests now. |
I ended up moving the existing |
This commit extracts MultiValueMapAdapter from CollectionUtils and reuses its implementation as base class of LinkedMultiValueMap. Closes gh-25140
This commit extracts MultiValueMapAdapter from CollectionUtils and reuses its implementation as base class of LinkedMultiValueMap. Closes gh-25140
This commit extracts MultiValueMapAdapter from CollectionUtils and reuses its implementation as base class of LinkedMultiValueMap. Closes spring-projectsgh-25140
This commit extracts MultiValueMapAdapter from CollectionUtils and reuses its implementation as base class of LinkedMultiValueMap. Closes spring-projectsgh-25140
If You create
MultiValueMap
viaMultiValueMapAdapter
, and value list is empty, call of methodgetFirst
fail onIndexOutOfBounds
exception:Good solution is:
The text was updated successfully, but these errors were encountered: