You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/08/03 06:07:46 UTC
svn commit: r1803950 - in /felix/trunk/configadmin: changelog.txt
src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
Author: cziegeler
Date: Thu Aug 3 06:07:46 2017
New Revision: 1803950
URL: http://svn.apache.org/viewvc?rev=1803950&view=rev
Log:
FELIX-5669 : Registering a PersistenceManager causes duplicate caches. Apply modified patch from Brandan Jeter
Modified:
felix/trunk/configadmin/changelog.txt
felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
Modified: felix/trunk/configadmin/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/changelog.txt?rev=1803950&r1=1803949&r2=1803950&view=diff
==============================================================================
--- felix/trunk/configadmin/changelog.txt (original)
+++ felix/trunk/configadmin/changelog.txt Thu Aug 3 06:07:46 2017
@@ -1,3 +1,9 @@
+Changes from 1.8.14 to 1.8.16
+-----------------------------
+** Bug
+ * [FELIX-5669] : Registering a PersistenceManager causes duplicate caches.
+
+
Changes from 1.8.12 to 1.8.14
-----------------------------
** Bug
Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java?rev=1803950&r1=1803949&r2=1803950&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java Thu Aug 3 06:07:46 2017
@@ -67,17 +67,22 @@ class CachingPersistenceManagerProxy imp
this.pm = pm;
this.cache = new Hashtable<String, CaseInsensitiveDictionary>();
}
-
+
public boolean isNotCachablePersistenceManager() {
return pm instanceof NotCachablePersistenceManager;
}
+ public PersistenceManager getDelegatee()
+ {
+ return pm;
+ }
/**
* Remove the configuration with the given PID. This implementation removes
* the entry from the cache before calling the underlying persistence
* manager.
*/
+ @Override
public void delete( String pid ) throws IOException
{
Lock lock = globalLock.writeLock();
@@ -99,6 +104,7 @@ class CachingPersistenceManagerProxy imp
* the existence in the cache. If not in the cache the underlying
* persistence manager is asked.
*/
+ @Override
public boolean exists( String pid )
{
Lock lock = globalLock.readLock();
@@ -124,6 +130,7 @@ class CachingPersistenceManagerProxy imp
* That is modifying the contents of a dictionary returned from this method
* has no influence on the dictionaries stored in the cache.
*/
+ @Override
public Enumeration getDictionaries() throws IOException
{
return getDictionaries( null );
@@ -200,6 +207,7 @@ class CachingPersistenceManagerProxy imp
* That is modifying the contents of a dictionary returned from this method
* has no influence on the dictionaries stored in the cache.
*/
+ @Override
public Dictionary load( String pid ) throws IOException
{
Lock lock = globalLock.readLock();
@@ -237,6 +245,7 @@ class CachingPersistenceManagerProxy imp
* is subsequent modification to the given dictionary has no influence on
* the cached data.
*/
+ @Override
public void store( String pid, Dictionary properties ) throws IOException
{
Lock lock = globalLock.writeLock();
Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=1803950&r1=1803949&r2=1803950&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java Thu Aug 3 06:07:46 2017
@@ -846,7 +846,12 @@ public class ConfigurationManager implem
Object service = persistenceManagerTracker.getService( refs[i] );
if ( service != null )
{
- pmList.add( new CachingPersistenceManagerProxy( ( PersistenceManager ) service ) );
+ CachingPersistenceManagerProxy proxy = getProxyForPersistenceManager(( PersistenceManager ) service );
+ if ( proxy == null )
+ {
+ proxy = new CachingPersistenceManagerProxy( ( PersistenceManager ) service );
+ }
+ pmList.add( proxy );
}
}
@@ -860,6 +865,17 @@ public class ConfigurationManager implem
return persistenceManagers;
}
+ private CachingPersistenceManagerProxy getProxyForPersistenceManager(final PersistenceManager pm)
+ {
+ if (persistenceManagers != null) {
+ for (final CachingPersistenceManagerProxy pmProxy : persistenceManagers) {
+ if (pmProxy.getDelegatee() == pm) {
+ return pmProxy;
+ }
+ }
+ }
+ return null;
+ }
private ServiceReference getServiceReference()
{