EHC ❯ NPE creating CacheManager with no config file
-
Bug
-
Status: Closed
-
2 Major
-
Resolution: Fixed
-
ehcache-core
-
-
alexsnaps
-
Reporter: amiller
-
April 20, 2010
-
0
-
Watchers: 0
-
May 21, 2010
-
April 21, 2010
Description
I needed to spin up a CacheManager and dynamically add/remove caches. I had no real reason to need a cache manager so just did this:
Configuration mgrConfig = new Configuration();
mgrConfig.setUpdateCheck(false);
this.cacheManager = new CacheManager(mgrConfig);
which yielded the following NPE in some TC code that assumes there is a default cache:
java.lang.NullPointerException
at net.sf.ehcache.CacheManager.init(CacheManager.java:313)
at net.sf.ehcache.CacheManager.
That’s a safe assumption when using a config file as that’s being validated but this programmatic path doesn’t validate that or at least hasn’t at the point where this error occurs.
Comments
Alexander Snaps 2010-04-21
Himadri Singh 2010-04-26
Verified in rev 2341, with fix got
Exception in thread “main” net.sf.ehcache.CacheException: Illegal configuration. No default cache is configured.
at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:211)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:550)
at net.sf.ehcache.CacheManager.init(CacheManager.java:323)
at net.sf.ehcache.CacheManager.
Ugly ugly fix imho I think we should really address EHC-692