You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
org.springframework.cache.interceptor.DefaultKeyGenerator has too weak hashing functionality [SPR-9377] #14013
This seems more or less a duplicate of #13675 and is IMHO a very ugly bug, not an improvement. Luckily I saw it during code review. :-) See my suggestion there.
Anyway, i did not find any strong recommendation not to use this default implementation, so people might use it without any limitations.
P.S. I created my own based on md5 hash, but i`m not ready to suggest it now:).
Regardless of possible better implementations, I believe there is a bug in the default implementation. If you have a method with only one object parameter, that parameter is never hashed, it's simply returned.
I've made my own key generator where I changed this:
Activity
spring-projects-issues commentedon May 8, 2012
Hans-Peter Störr commented
This seems more or less a duplicate of #13675 and is IMHO a very ugly bug, not an improvement. Luckily I saw it during code review. :-) See my suggestion there.
spring-projects-issues commentedon May 8, 2012
Andrey Karandey commented
Anyway, i did not find any strong recommendation not to use this default implementation, so people might use it without any limitations.
P.S. I created my own based on md5 hash, but i`m not ready to suggest it now:).
spring-projects-issues commentedon May 9, 2012
Hans-Peter Störr commented
md5 would be better, but I'd rather not use any kind of hashing - see my comment on #13675.
spring-projects-issues commentedon May 15, 2012
Tim Lenz commented
Regardless of possible better implementations, I believe there is a bug in the default implementation. If you have a method with only one object parameter, that parameter is never hashed, it's simply returned.
I've made my own key generator where I changed this:
if (params.length == 1) {
return (params[0] == null ? NULL_PARAM_KEY : params[0]);
}
to this:
if (params.length == 1 && params[0] == null) {
return NULL_PARAM_KEY;
}
Now a single non-null object parameter will still be hashed, as occurred already for methods with more than one parameter.