ehcache / ehcache-shiro Goto Github PK
View Code? Open in Web Editor NEWEhcache 3 module for Apache Shiro integration
License: Apache License 2.0
Ehcache 3 module for Apache Shiro integration
License: Apache License 2.0
The current implementation is open to races.
Calling EhcacheShiroManager.init()
followed byEhcacheShiroManager.setCacheManager
will make the 'EhcacheShiroManager' close the passed CacheManager on destroy()
although its lifecycle is supposed to be managed outside.
Assuming we can make that return collection unmodifiable - which seems to be the case in current implementation of the ehcache 2.x module, it would be better to have a delegation model to the cache, thus making sure we do not have to materialise the whole value collection on heap.
Calling EhcacheShiroManager.init()
followed by EhcacheShiroManager.setCacheManager
will make the EhCache's CacheManager created by 'EhcacheShiroManager' unreachable. Consider the following test case:
EhcacheShiroManager ehcacheShiroManager = new EhcacheShiroManager();
ehcacheShiroManager.init();
CacheManager firstCacheManager = ehcacheShiroManager.getCacheManager();
Assert.assertNotNull(firstCacheManager);
ehcacheShiroManager.setCacheManager(cacheManager);
CacheManager secondCacheManager = ehcacheShiroManager.getCacheManager();
Assert.assertNotSame(firstCacheManager, secondCacheManager);
Assert.assertNotEquals(firstCacheManager, secondCacheManager);
ehcacheShiroManager.destroy();
Assert.assertEquals(Status.UNINITIALIZED, firstCacheManager.getStatus());
Assert.assertEquals(Status.UNINITIALIZED, secondCacheManager.getStatus());
The current implementation is open to races.
Hi, I just tried use the library for my project.
but I found there is a issue in method getResource in class EhcacheShiroManager
the line 164. I found the code always strip the prefix. but when we put the path into. the code use a url for it.
then it always throws a MalformedURLException, and Caused by: java.net.MalformedURLException: no protocol:
I suppose this is a bug for this code.
thanks
Mike
The current implementation is opened to races.
Hi there,
if a cache is not configured in ehcache.xml
, you'll get a NPE.
The problamatic part is configurationbuilder which can be null. You still call the build() method without checking.
Suggestion:
if (null == configurationBuilder) {
throw new IllegalStateException("No configuration for the cache with the name [" + name + "] was found. "
+ "Please add it to your ehcache.xml file.");
}
Current code hardcodes the configuration to a specific XML file.
There should be an option - in a Shiro compatible way ideally - to specify a custom config file.
Also we should not read the config file each time a cache needs to be created as is currently the case.
Assuming we can make that return collection unmodifiable - which seems to be the case in current implementation of the ehcache 2.x module, it would be better to have a delegation model to the cache, thus making sure we do not have to materialise the whole key set on heap.
Looking at what has been picked right now, I would change to the following:
org.ehcache.integrations.shiro
shiro-ehcache3
And we also need to decide on a version. Something close to Shiro? To Ehcache 3? or simply independent?
Comments / counter proposals welcome!
From a quick look, org.apache.shiro:shiro-core:1.1.0
provides already the caching API.
If we could announce that our module works with versions 1.1.0
and above (or even older ... just checked Maven Central but maybe other version exist elsewhere) it would be awesome.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.