apache / apache/grails-core

CustomCacheKeyGenerator key generator not hashing class or method names or params

Open
#14,165 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-cache
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

The compilation of CustomCacheKeyGenerator.groovy [CacheKey.hashCode()](https://github.com/grails-plugins/grails-cache/blob/c442583e552e03d297ee1aa144daf716a80c509f/src/ast/groovy/grails/plugin/cache/CustomCacheKeyGenerator.groovy#L56-L69) and [TemporaryGrailsCacheKey.hashCode()](https://github.com/grails-plugins/grails-cache/blob/c442583e552e03d297ee1aa144daf716a80c509f/src/ast/groovy/grails/plugin/cache/CustomCacheKeyGenerator.groovy#L141-L154) implementation into bytecode ignores the `targetClassName`, `targetMethodName` & `simpleKey`

decompiled bytecode:
```
public int hashCode() {
int prime = 31;
int result = 1;
int var3 = prime * result;
boolean var10000;
if (this.simpleKey == null) {
var10000 = false;
} else {
this.simpleKey.hashCode();
}

int var4 = prime * var3;
if (this.targetClassName == null) {
var10000 = false;
} else {
this.targetClassName.hashCode();
}

int var5 = prime * var4;
if (this.targetMethodName == null) {
var10000 = false;
} else {
this.targetMethodName.hashCode();
}

int var6 = prime * var5 + this.targetObjectHashCode;
return var6;
}
```

Contributor guide

Open the contributing guide

Research direction

Start in src/ast/groovy/grails/plugin/cache/CustomCacheKeyGenerator.groovy at CacheKey.hashCode() and TemporaryGrailsCacheKey.hashCode(), then compare the Groovy source with the decompiled bytecode shown in the issue. Done means the compiled hashCode implementations account for targetClassName, targetMethodName, and simpleKey rather than discarding their hash values.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.