Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Conversation

@camac
Copy link

@camac camac commented Sep 9, 2016

Due to incorrect logic it was impossible to clear the cache / refresh for a single entry in the cache.

For example when using the userBean / peopleBean, if you tried to use peopleBean.clearCache(@UserName) it had no effect.

e.g. this was annoying if you added some accessRoles to user and just wanted to refresh that user's peopleBean entry.
As specified in this StackOverflow question

This is because of 3 bugs in the clearCache method

  1. the tests for each scope if (c==null) should actually be if (c!=null). This was preventing the code from entering into the 'remove' condition
  2. The 'remove' method was incorrectly being called on the scope map e.g. sessionScope instead of the system cache that was retrieved
  3. The 'remove' method was using the 'CACHE_KEY' when it should actually be using the id

Note: the clearCache() method to clear the entire cache was working correctly, however I think this must have been copy/pasted to the clearCache(String) method and not correctly tidied up

Note I changed the synchronized statement to synchronize on the systemcache instead of the scope map. I assume this is correct but I am no expert on concurrency!

…eBean / any AbstractResourceProvider

Due to incorrect logic it was impossible to clear the cache / refresh for a single entry in the cache.

For example when using the userBean / peopleBean, if you tried to use peopleBean.clearCache(@UserName) it had no effect.

This is because of 3 bugs in the clearCache method

1. the tests for each scope if (c==null) should actually be if (c!=null). This was preventing the code from entering into the 'remove' condition
2. The 'remove' method was incorrectly being called on the scope map e.g. sessionScope instead of the system cache that was retrieved
3. The 'remove' method was using the 'CACHE_KEY' when it should actually be using the id

Note: the clearCache() method to clear the entire cache was working correctly, however I think this must have been copy/pasted to the clearCache(String) method and not correctly tidied up
@padraic-edwards
Copy link
Contributor

Hi Cameron, we'll review this fix and look to get it included in a post FP8 OpenNTF extlib release.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants