Status/Resolution/Reason: Closed/Withdrawn/NotABug
Reporter/Name(from Bugbase): Jork Zijlstra / Jork Zijlstra (Jork Zijlstra)
Created: 05/18/2015
Components: Caching
Versions: 11.0
Failure Type: Usability Issue
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Major / All users will encounter
Locale/System: English / Linux Ubuntu 10.10
Vote Count: 0
Problem Description:
Object that are in put in the cache with cachput can be unintentionally edited afterwards when getting it from the cache with cacheget and then update it.
cacheGet return values by reference, except for simpleValues / arrays (The normal by reference / copy rules seems to apply here).
Steps to Reproduce:
private any function _getCacheTimeSpan()
{
return createTimeSpan(6, randRange(1,23), randRange(1,59),0);
}
function test()
{
var cachekey = "test";
var originalValues = {
"test" = "test"
};
cachePut(cachekey & "_" & cachekey, originalValues, _getCacheTimeSpan());
var expectedDuplicate = cacheGet(cachekey & "_" & cachekey);
structUpdate(originalValues, "test", "test2");
writeDump(expectedDuplicate);
}
test();
Actual Result:
expectedDuplicate are updated
Expected Result:
expectedDuplicate aren't updated
Any Workarounds:
- Duplicate it when using cacheget
- Seralize the object when using cacheput, deserialize when cacheget
- for Query use getShallowCopy after cacheGet, so that iterators won't be shared
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3989480
External Customer Info:
External Company:
External Customer Name: Jork
External Customer Email:
External Test Config: My Hardware and Environment details:
Ubuntu 14.04 - CF11,0,05,293506
Attachments:
Comments: