[
https://issues.apache.org/jira/browse/FC-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shawn McKinney resolved FC-106.
-------------------------------
Resolution: Fixed
Has been resolved. The cache initialization has been moved to a static block.
No more synch:
static
{
String cacheConfig = Config.getProperty( EHCACHE_CONFIG_FILE );
try
{
// This static block performs the following:
// 1. Construct an instance of Ehcache's CacheManager object.
// 2. Requires location of ehcache's config file as parameter.
// 3. The CacheManager reference then gets passed to constructor of
self.
// 4. Store the reference of self as a static member variable of
this class.
mFtCacheImpl = new CacheMgr( new CacheManager(
ClassUtil.resourceAsStream( cacheConfig ) ) );
}
catch(CfgException ce)
{
// The ehcache file cannot be located on this program's classpath.
Ehcache is required, throw runtime exception.
LOG.error( "CfgException caught in static initializer=" +
ce.getMessage());
throw new CfgRuntimeException(
GlobalErrIds.FT_CACHE_NOT_CONFIGURED, cacheConfig, ce );
}
}
/**
* Private constructor.
*
* @param cacheMangerImpl contains a reference to cache implementation
manager.
*/
/**
* Create or return the fortress cache manager reference.
* @return handle to the cache manager in effect for process.
*/
public static CacheMgr getInstance()
{
return mFtCacheImpl;
}
> There is something fishy in the CacheMgr class
> ----------------------------------------------
>
> Key: FC-106
> URL: https://issues.apache.org/jira/browse/FC-106
> Project: FORTRESS
> Issue Type: Improvement
> Affects Versions: 1.0.0-RC40
> Reporter: Emmanuel Lecharny
> Fix For: 1.0.0-RC41
>
>
> The class does not expose a constructor : we use the {{getInstance()}} method
> to get an instance of it. So far, so good, except that we create the instance
> into a static method, when it should be done in a static block. That would
> remove the need for a lock, and remove the mix of non static fields and
> static fields.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)