-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
LinkedCaseInsensitiveMap#getOrDefault
should return default value instead of null
#33134
LinkedCaseInsensitiveMap#getOrDefault
should return default value instead of null
#33134
Conversation
This method directly calls the LinkedHashMap # get of the parent class, but after obtaining the value, it does not determine whether it is a null value
@poying9464 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@poying9464 Thank you for signing the Contributor License Agreement! |
Method
I don't think this is a bug but I also wait for confirming from Spring team |
The method |
I took a look at this as well, and I think there's actually a bug in the implementation. Specifically, I believe public V getOrDefault(Object key, V defaultValue) {
if (key instanceof String string) {
String caseInsensitiveKey = this.caseInsensitiveKeys.get(convertKey(string));
if (caseInsensitiveKey != null) {
return this.targetMap.getOrDefault(caseInsensitiveKey, defaultValue);
}
}
return defaultValue;
} @sdeleuze, what do you think? |
LinkedCaseInsensitiveMap#getOrDefault
should return default value instead of null
I took a closer look and realized that the Thus, there is no need to invoke @poying9464, please note that we have tests in In light of the above, I am re-closing this issue as @sdeleuze had originally. |
Although this method has the |
Hi @poying9464,
As I mentioned above, it is already implemented according to the contract of See the following tests for details. Lines 70 to 92 in 1ea4eb1
|
This method directly calls the LinkedHashMap # get of the parent class,
but after obtaining the value, it does not determine whether it is a null value