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 2016/10/21 15:18:20 UTC

svn commit: r1766046 - in /felix/trunk/configadmin-1.8.x: ./ src/main/java/org/apache/felix/cm/impl/ src/main/java/org/apache/felix/cm/impl/helper/ src/main/resources/OSGI-INF/ src/test/java/org/apache/felix/cm/file/ src/test/java/org/apache/felix/cm/i...

Author: cziegeler
Date: Fri Oct 21 15:18:20 2016
New Revision: 1766046

URL: http://svn.apache.org/viewvc?rev=1766046&view=rev
Log:
Port changes from main branch to 1.8.x branch

Modified:
    felix/trunk/configadmin-1.8.x/changelog.txt
    felix/trunk/configadmin-1.8.x/pom.xml
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/RankingComparator.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceFactoryTracker.java
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceTracker.java
    felix/trunk/configadmin-1.8.x/src/main/resources/OSGI-INF/permissions.perm
    felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java
    felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
    felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java

Modified: felix/trunk/configadmin-1.8.x/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/changelog.txt?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/changelog.txt (original)
+++ felix/trunk/configadmin-1.8.x/changelog.txt Fri Oct 21 15:18:20 2016
@@ -1,8 +1,21 @@
+Changes from 1.8.10 to 1.8.12
+-----------------------------
+
+** Improvement
+    * [FELIX-5380] - Reduce quite useless log verbosity
+    * [FELIX-5366] - Additional Unit Tests for ConfigurationHandler
+
+** Bug
+    * [FELIX-5368] - ConfigurationManager ignores NotCachablePersistenceManager marker interface
+    * [FELIX-5385] - ConfigAdmin uses wrong security when calling ManagedServices
+
+
 Changes from 1.8.8 to 1.8.10
 ----------------------------
 
 ** Improvement
     * [FELIX-5088] - CaseSensitiveDictionary should implement equals()
+    * [FELIX-5211] - Use provide/require capabilities instead of obsolete and meaningless import-export service headers
 
 ** Bug
     * [FELIX-5301] - ConfigurationPlugin support is not spec compliant

Modified: felix/trunk/configadmin-1.8.x/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/pom.xml?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/pom.xml (original)
+++ felix/trunk/configadmin-1.8.x/pom.xml Fri Oct 21 15:18:20 2016
@@ -22,8 +22,8 @@
     <parent>
         <groupId>org.apache.felix</groupId>
         <artifactId>felix-parent</artifactId>
-        <version>3</version>
-        <relativePath>../pom/pom.xml</relativePath>
+        <version>4</version>
+        <relativePath/>
     </parent>
 
     <artifactId>org.apache.felix.configadmin</artifactId>
@@ -68,6 +68,7 @@
         in the IDE launcher. 
     -->
     <properties>
+        <felix.java.version>6</felix.java.version>
         <bundle.build.name>
             ${basedir}/target
         </bundle.build.name>

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java Fri Oct 21 15:18:20 2016
@@ -67,6 +67,10 @@ class CachingPersistenceManagerProxy imp
         this.pm = pm;
         this.cache = new Hashtable<String, CaseInsensitiveDictionary>();
     }
+    
+    public boolean isNotCachablePersistenceManager() {
+        return pm instanceof NotCachablePersistenceManager;
+    }
 
 
     /**

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java Fri Oct 21 15:18:20 2016
@@ -49,6 +49,7 @@ public class ConfigurationAdapter implem
     /**
      * @see org.apache.felix.cm.impl.ConfigurationImpl#getPid()
      */
+    @Override
     public String getPid()
     {
         checkDeleted();
@@ -59,6 +60,7 @@ public class ConfigurationAdapter implem
     /**
      * @see org.apache.felix.cm.impl.ConfigurationImpl#getFactoryPid()
      */
+    @Override
     public String getFactoryPid()
     {
         checkDeleted();
@@ -69,12 +71,13 @@ public class ConfigurationAdapter implem
     /**
      * @see org.apache.felix.cm.impl.ConfigurationImpl#getBundleLocation()
      */
+    @Override
     public String getBundleLocation()
     {
         // CM 1.4 / 104.13.2.4
         final String bundleLocation = delegatee.getBundleLocation();
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getBundleLocation() ==> {0}", new Object[]
-            { bundleLocation } );
+        //delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getBundleLocation() ==> {0}", new Object[]
+        //    { bundleLocation } );
         checkActive();
         configurationAdmin.checkPermission( delegatee.getConfigurationManager(), ( bundleLocation == null ) ? "*" : bundleLocation, true );
         checkDeleted();
@@ -86,6 +89,7 @@ public class ConfigurationAdapter implem
      * @param bundleLocation
      * @see org.apache.felix.cm.impl.ConfigurationImpl#setStaticBundleLocation(String)
      */
+    @Override
     public void setBundleLocation( String bundleLocation )
     {
         delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "setBundleLocation(bundleLocation={0})",
@@ -106,6 +110,7 @@ public class ConfigurationAdapter implem
      * @throws IOException
      * @see org.apache.felix.cm.impl.ConfigurationImpl#update()
      */
+    @Override
     public void update() throws IOException
     {
         delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "update()", ( Throwable ) null );
@@ -134,7 +139,7 @@ public class ConfigurationAdapter implem
 
     public Dictionary getProperties()
     {
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getProperties()", ( Throwable ) null );
+        //delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getProperties()", ( Throwable ) null );
 
         checkDeleted();
 
@@ -144,9 +149,10 @@ public class ConfigurationAdapter implem
     }
 
 
+    @Override
     public long getChangeCount()
     {
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getChangeCount()", ( Throwable ) null );
+        //delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getChangeCount()", ( Throwable ) null );
 
         checkDeleted();
 
@@ -158,6 +164,7 @@ public class ConfigurationAdapter implem
      * @throws IOException
      * @see org.apache.felix.cm.impl.ConfigurationImpl#delete()
      */
+    @Override
     public void delete() throws IOException
     {
         delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "delete()", ( Throwable ) null );
@@ -171,6 +178,7 @@ public class ConfigurationAdapter implem
     /**
      * @see org.apache.felix.cm.impl.ConfigurationImpl#hashCode()
      */
+    @Override
     public int hashCode()
     {
         return delegatee.hashCode();
@@ -181,6 +189,7 @@ public class ConfigurationAdapter implem
      * @param obj
      * @see org.apache.felix.cm.impl.ConfigurationImpl#equals(java.lang.Object)
      */
+    @Override
     public boolean equals( Object obj )
     {
         return delegatee.equals( obj );
@@ -190,6 +199,7 @@ public class ConfigurationAdapter implem
     /**
      * @see org.apache.felix.cm.impl.ConfigurationImpl#toString()
      */
+    @Override
     public String toString()
     {
         return delegatee.toString();

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java Fri Oct 21 15:18:20 2016
@@ -70,6 +70,7 @@ public class ConfigurationAdminImpl impl
     /* (non-Javadoc)
      * @see org.osgi.service.cm.ConfigurationAdmin#createFactoryConfiguration(java.lang.String)
      */
+    @Override
     public Configuration createFactoryConfiguration( String factoryPid ) throws IOException
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
@@ -87,6 +88,7 @@ public class ConfigurationAdminImpl impl
     /* (non-Javadoc)
      * @see org.osgi.service.cm.ConfigurationAdmin#createFactoryConfiguration(java.lang.String, java.lang.String)
      */
+    @Override
     public Configuration createFactoryConfiguration( String factoryPid, String location ) throws IOException
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
@@ -106,6 +108,7 @@ public class ConfigurationAdminImpl impl
     /* (non-Javadoc)
      * @see org.osgi.service.cm.ConfigurationAdmin#getConfiguration(java.lang.String)
      */
+    @Override
     public Configuration getConfiguration( String pid ) throws IOException
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
@@ -147,6 +150,7 @@ public class ConfigurationAdminImpl impl
     /* (non-Javadoc)
      * @see org.osgi.service.cm.ConfigurationAdmin#getConfiguration(java.lang.String, java.lang.String)
      */
+    @Override
     public Configuration getConfiguration( String pid, String location ) throws IOException
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
@@ -175,6 +179,7 @@ public class ConfigurationAdminImpl impl
     /* (non-Javadoc)
      * @see org.osgi.service.cm.ConfigurationAdmin#listConfigurations(java.lang.String)
      */
+    @Override
     public Configuration[] listConfigurations( String filter ) throws IOException, InvalidSyntaxException
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
@@ -239,6 +244,25 @@ public class ConfigurationAdminImpl impl
      */
     void checkPermission( final ConfigurationManager configurationManager, String name, boolean checkOwn )
     {
+        checkPermission(configurationManager, name, ConfigurationPermission.CONFIGURE, checkOwn);
+    }
+
+    /**
+     * Checks whether the current access control context (call stack) has
+     * the given permission for the given bundle location and throws a
+     * <code>SecurityException</code> if this is not the case.
+     *
+     * @param name The bundle location to check for permission. If this
+     *      is <code>null</code> permission is always granted.
+     * @param action The action to check.
+     * @param checkOwn If {@code false} permission is alwas granted if
+     *      {@code name} is the same the using bundle's location.
+     *
+     * @throws SecurityException if the access control context does not
+     *      have the appropriate permission
+     */
+    void checkPermission( final ConfigurationManager configurationManager, String name, String action, boolean checkOwn )
+    {
         // the caller's permission must be checked
         final SecurityManager sm = System.getSecurityManager();
         if ( sm != null )
@@ -248,45 +272,45 @@ public class ConfigurationAdminImpl impl
             {
                 try
                 {
-                    sm.checkPermission( new ConfigurationPermission( name, ConfigurationPermission.CONFIGURE ) );
+                    sm.checkPermission( new ConfigurationPermission( name, action ) );
 
                     configurationManager.log( LogService.LOG_DEBUG,
-                        "Explicit Permission; grant CONFIGURE permission on configuration bound to {0} to bundle {1}",
+                        "Explicit Permission; grant {0} permission on configuration bound to {1} to bundle {2}",
                         new Object[]
-                            { name, getBundle().getLocation() } );
+                            { action, name, getBundle().getLocation() } );
                 }
                 catch ( SecurityException se )
                 {
                     configurationManager
                         .log(
                             LogService.LOG_DEBUG,
-                            "No Permission; denied CONFIGURE permission on configuration bound to {0} to bundle {1}; reason: {2}",
+                            "No Permission; denied {0} permission on configuration bound to {1} to bundle {2}; reason: {3}",
                             new Object[]
-                                { name, getBundle().getLocation(), se.getMessage() } );
+                                { action, name, getBundle().getLocation(), se.getMessage() } );
                     throw se;
                 }
             }
             else if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
             {
                 configurationManager.log( LogService.LOG_DEBUG,
-                    "Implicit Permission; grant CONFIGURE permission on configuration bound to {0} to bundle {1}",
+                    "Implicit Permission; grant {0} permission on configuration bound to {1} to bundle {2}",
                     new Object[]
-                        { name, getBundle().getLocation() } );
+                        { action, name, getBundle().getLocation() } );
 
             }
         }
         else if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
         {
             configurationManager.log( LogService.LOG_DEBUG,
-                "No SecurityManager installed; grant CONFIGURE permission on configuration bound to {0} to bundle {1}",
+                "No SecurityManager installed; grant {0} permission on configuration bound to {1} to bundle {2}",
                 new Object[]
-                    { name, getBundle().getLocation() } );
+                    { action, name, getBundle().getLocation() } );
         }
     }
 
 
     /**
-     * Returns the {@link ConfigurationManager} backing this configuraiton
+     * Returns the {@link ConfigurationManager} backing this configuration
      * admin instance or throws {@code IllegalStateException} if already
      * disposed off.
      *

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java Fri Oct 21 15:18:20 2016
@@ -362,7 +362,7 @@ public class ConfigurationImpl extends C
     }
 
 
-    /* (non-Javadoc)
+    /**
      * @see org.osgi.service.cm.Configuration#update(java.util.Dictionary)
      */
     public void update( Dictionary properties ) throws IOException
@@ -397,6 +397,7 @@ public class ConfigurationImpl extends C
 
     //---------- Object overwrites --------------------------------------------
 
+    @Override
     public boolean equals( Object obj )
     {
         if ( obj == this )
@@ -413,12 +414,14 @@ public class ConfigurationImpl extends C
     }
 
 
+    @Override
     public int hashCode()
     {
         return getPidString().hashCode();
     }
 
 
+    @Override
     public String toString()
     {
         return "Configuration PID=" + getPidString() + ", factoryPID=" + factoryPID + ", bundleLocation=" + getBundleLocation();
@@ -494,6 +497,7 @@ public class ConfigurationImpl extends C
     }
 
 
+    @Override
     void store() throws IOException
     {
         // we don't need a deep copy, since we are not modifying

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java Fri Oct 21 15:18:20 2016
@@ -197,6 +197,7 @@ public class ConfigurationManager implem
     // flag indicating whether the manager is considered alive
     private volatile boolean isActive;
 
+    @Override
     public void start( BundleContext bundleContext )
     {
         // track the log service using a ServiceTracker
@@ -293,6 +294,7 @@ public class ConfigurationManager implem
     }
 
 
+    @Override
     public void stop( BundleContext bundleContext )
     {
 
@@ -681,7 +683,11 @@ public class ConfigurationManager implem
                 }
 
                 // ensure the service.pid and returned a cached config if available
-                ConfigurationImpl cfg = getCachedConfiguration( pid );
+                ConfigurationImpl cfg = null;
+                if (! (pmList[i].isNotCachablePersistenceManager())) 
+                {
+                    cfg = getCachedConfiguration( pid );
+                }
                 if ( cfg == null )
                 {
                     cfg = new ConfigurationImpl( this, pmList[i], config );
@@ -786,6 +792,7 @@ public class ConfigurationManager implem
 
     // ---------- BundleListener -----------------------------------------------
 
+    @Override
     public void bundleChanged( BundleEvent event )
     {
         if ( event.getType() == BundleEvent.UNINSTALLED && handleBundleEvents )
@@ -1399,6 +1406,7 @@ public class ConfigurationManager implem
         }
 
 
+        @Override
         public void run()
         {
             for ( String pid : this.pids )
@@ -1484,6 +1492,7 @@ public class ConfigurationManager implem
         }
 
 
+        @Override
         public void run()
         {
             for ( String factoryPid : this.factoryPids )
@@ -1724,6 +1733,7 @@ public class ConfigurationManager implem
         }
 
 
+        @Override
         public void run()
         {
             log( LogService.LOG_DEBUG, "Updating configuration {0} to revision #{1}", new Object[]
@@ -1813,6 +1823,7 @@ public class ConfigurationManager implem
         }
 
 
+        @Override
         public void run()
         {
             List<ServiceReference<?>> srList = this.getHelper().getServices( getTargetedServicePid() );
@@ -1886,6 +1897,7 @@ public class ConfigurationManager implem
         }
 
 
+        @Override
         public void run()
         {
             List<ServiceReference<?>> srList = this.getHelper().getServices( getTargetedServicePid() );
@@ -2016,6 +2028,7 @@ public class ConfigurationManager implem
         }
 
 
+        @Override
         public void run()
         {
             for ( int i = 0; i < listeners.length; i++ )

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/RankingComparator.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/RankingComparator.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/RankingComparator.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/RankingComparator.java Fri Oct 21 15:18:20 2016
@@ -95,16 +95,16 @@ public abstract class RankingComparator
             final long id1 = this.getLong( obj1, Constants.SERVICE_ID );
             final long id2 = this.getLong( obj2, Constants.SERVICE_ID );
 
+            if ( id1 == id2 )
+            {
+                return 0;
+            }
+
             final int rank1 = this.getInteger( obj1, ConfigurationPlugin.CM_RANKING );
             final int rank2 = this.getInteger( obj2, ConfigurationPlugin.CM_RANKING );
 
             if ( rank1 == rank2 )
             {
-                if ( id1 == id2 )
-                {
-                    return 0;
-                }
-
                 return ( id1 > id2 ) ? -1 : 1;
             }
 

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java Fri Oct 21 15:18:20 2016
@@ -20,6 +20,9 @@ package org.apache.felix.cm.impl.helper;
 
 
 import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.DomainCombiner;
+import java.security.Permission;
 import java.security.ProtectionDomain;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -30,6 +33,7 @@ import java.util.List;
 import org.apache.felix.cm.impl.CaseInsensitiveDictionary;
 import org.apache.felix.cm.impl.ConfigurationManager;
 import org.apache.felix.cm.impl.RankingComparator;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationException;
@@ -286,9 +290,41 @@ public abstract class BaseTracker<S> ext
     }
 
 
-    protected AccessControlContext getAccessControlContext( final Object ref )
+    AccessControlContext getAccessControlContext( final Bundle bundle )
     {
-        return new AccessControlContext( new ProtectionDomain[]
-            { ref.getClass().getProtectionDomain() } );
+        return new AccessControlContext(AccessController.getContext(), new CMDomainCombiner(bundle));
     }
-}
\ No newline at end of file
+
+    private static class CMDomainCombiner implements DomainCombiner {
+        private final Bundle bundle;
+
+        CMDomainCombiner(Bundle bundle) {
+            this.bundle = bundle;
+        }
+
+        public ProtectionDomain[] combine(ProtectionDomain[] arg0,
+                                          ProtectionDomain[] arg1) {
+            return new ProtectionDomain[] { new CMProtectionDomain(bundle) };
+        }
+
+    }
+
+    private static class CMProtectionDomain extends ProtectionDomain {
+
+        private final Bundle bundle;
+
+        CMProtectionDomain(Bundle bundle) {
+            super(null, null);
+            this.bundle = bundle;
+        }
+
+        public boolean implies(Permission permission) {
+            try {
+                return bundle.hasPermission(permission);
+            } catch (IllegalStateException e) {
+                return false;
+            }
+        }
+    }
+
+}

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceFactoryTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceFactoryTracker.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceFactoryTracker.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceFactoryTracker.java Fri Oct 21 15:18:20 2016
@@ -90,7 +90,7 @@ public class ManagedServiceFactoryTracke
             {
                 Dictionary props = getProperties( properties, reference, configPid.toString(),
                     factoryPid.toString() );
-                updated( service, configPid.toString(), props );
+                updated( reference, service, configPid.toString(), props );
                 configs.record( configPid, factoryPid, revision );
             }
             catch ( Throwable t )
@@ -117,7 +117,7 @@ public class ManagedServiceFactoryTracke
             {
                 try
                 {
-                    deleted( service, configPid.toString() );
+                    deleted( reference, service, configPid.toString() );
                     configs.record( configPid, factoryPid, -1 );
                 }
                 catch ( Throwable t )
@@ -133,7 +133,7 @@ public class ManagedServiceFactoryTracke
     }
 
 
-    private void updated( final ManagedServiceFactory service, final String pid, final Dictionary properties )
+    private void updated( final ServiceReference<ManagedServiceFactory> reference, final ManagedServiceFactory service, final String pid, final Dictionary properties )
         throws ConfigurationException
     {
         if ( System.getSecurityManager() != null )
@@ -147,7 +147,7 @@ public class ManagedServiceFactoryTracke
                         service.updated( pid, properties );
                         return null;
                     }
-                }, getAccessControlContext( service ) );
+                }, getAccessControlContext( reference.getBundle() ) );
             }
             catch ( PrivilegedActionException e )
             {
@@ -161,7 +161,7 @@ public class ManagedServiceFactoryTracke
     }
 
 
-    private void deleted( final ManagedServiceFactory service, final String pid )
+    private void deleted( final ServiceReference<ManagedServiceFactory> reference, final ManagedServiceFactory service, final String pid )
     {
         if ( System.getSecurityManager() != null )
         {
@@ -172,11 +172,11 @@ public class ManagedServiceFactoryTracke
                     service.deleted( pid );
                     return null;
                 }
-            }, getAccessControlContext( service ) );
+            }, getAccessControlContext( reference.getBundle() ) );
         }
         else
         {
             service.deleted( pid );
         }
     }
-}
\ No newline at end of file
+}

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceTracker.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceTracker.java (original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/helper/ManagedServiceTracker.java Fri Oct 21 15:18:20 2016
@@ -149,7 +149,7 @@ public class ManagedServiceTracker exten
         {
             try
             {
-                updated( srv, properties );
+                updated( service, srv, properties );
                 configs.record( configPid, null, revision );
             }
             catch ( Throwable t )
@@ -164,7 +164,7 @@ public class ManagedServiceTracker exten
     }
 
 
-    private void updated( final ManagedService service, final Dictionary properties ) throws ConfigurationException
+    private void updated( final ServiceReference<ManagedService> reference, final ManagedService service, final Dictionary properties) throws ConfigurationException
     {
         if ( System.getSecurityManager() != null )
         {
@@ -177,7 +177,7 @@ public class ManagedServiceTracker exten
                         service.updated( properties );
                         return null;
                     }
-                }, getAccessControlContext( service ) );
+                }, getAccessControlContext( reference.getBundle() ) );
             }
             catch ( PrivilegedActionException e )
             {
@@ -189,4 +189,4 @@ public class ManagedServiceTracker exten
             service.updated( properties );
         }
     }
-}
\ No newline at end of file
+}

Modified: felix/trunk/configadmin-1.8.x/src/main/resources/OSGI-INF/permissions.perm
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/resources/OSGI-INF/permissions.perm?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/resources/OSGI-INF/permissions.perm (original)
+++ felix/trunk/configadmin-1.8.x/src/main/resources/OSGI-INF/permissions.perm Fri Oct 21 15:18:20 2016
@@ -47,4 +47,4 @@
 (org.osgi.framework.ServicePermission "org.apache.felix.cm.PersistenceManager" "register")
 
 # -> BaseTracker.getAccessControlContext
-(java.lang.RuntimePermission "getProtectionDomain")
+(java.security.SecurityPermission "createAccessControlContext")

Modified: felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java (original)
+++ felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java Fri Oct 21 15:18:20 2016
@@ -19,13 +19,21 @@
 package org.apache.felix.cm.file;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
 import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class ConfigurationHandlerTest extends TestCase
-{
+public class ConfigurationHandlerTest {
+    
+    private static final String SERVICE_PID = "service.pid";
 
     private static final String PAR_1 = "mongouri";
     private static final String VAL_1 = "127.0.0.1:27017";
@@ -39,11 +47,271 @@ public class ConfigurationHandlerTest ex
         "  # custom datastore\n" +
         PAR_2 + "=B\"" + VAL_2 + "\"\n";
 
+    @Test
     public void testComments() throws IOException
     {
         final Dictionary dict = ConfigurationHandler.read(new ByteArrayInputStream(CONFIG.getBytes("UTF-8")));
-        assertEquals(2, dict.size());
-        assertEquals(VAL_1, dict.get(PAR_1));
-        assertEquals(VAL_2, dict.get(PAR_2).toString());
+        Assert.assertEquals(2, dict.size());
+        Assert.assertEquals(VAL_1, dict.get(PAR_1));
+        Assert.assertEquals(VAL_2, dict.get(PAR_2).toString());
+    }
+ 
+    
+    @Test
+    public void test_writeArray() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Object> properties = new Hashtable< String, Object>();
+        properties.put(SERVICE_PID , new String [] {"foo", "bar"});
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=[ \\\r\n  \"foo\", \\\r\n  \"bar\", \\\r\n  ]\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeEmptyCollection() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Object> properties = new Hashtable< String, Object>();
+        properties.put(SERVICE_PID , new ArrayList());
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=( \\\r\n)\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeCollection() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Object> properties = new Hashtable< String, Object>();
+        List list = new ArrayList<String>(){{
+            add("foo");
+            add("bar");
+        }};
+        
+        properties.put(SERVICE_PID , list);
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=( \\\r\n  \"foo\", \\\r\n  \"bar\", \\\r\n)\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeSimpleString() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, String> properties = new Hashtable< String, String>();
+        properties.put(SERVICE_PID, "com.adobe.granite.foo.Bar");
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=\"com.adobe.granite.foo.Bar\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeInteger() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Integer> properties = new Hashtable< String, Integer>();
+        properties.put(SERVICE_PID, 1000);
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=I\"1000\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeLong() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Long> properties = new Hashtable< String, Long>();
+        properties.put(SERVICE_PID, 1000L);
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=L\"1000\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeFloat() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Float> properties = new Hashtable< String, Float>();
+        properties.put(SERVICE_PID, 3.6f);
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=F\"1080452710\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeDouble() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Double> properties = new Hashtable< String, Double>();
+        properties.put(SERVICE_PID, 3.6d);
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=D\"4615288898129284301\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeByte() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Byte> properties = new Hashtable< String, Byte>();
+        properties.put(SERVICE_PID, new Byte("10"));
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=X\"10\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeShort() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Short> properties = new Hashtable< String, Short>();
+        properties.put(SERVICE_PID, (short)10);
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=S\"10\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeChar() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Character> properties = new Hashtable< String, Character>();
+        properties.put(SERVICE_PID, 'c');
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=C\"c\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeBoolean() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, Boolean> properties = new Hashtable< String, Boolean>();
+        properties.put(SERVICE_PID, true);
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("service.pid=B\"true\"\r\n", entry);
+    }
+    
+    @Test
+    public void test_writeSimpleStringWithError() throws IOException {
+        OutputStream out = new ByteArrayOutputStream();
+        Dictionary< String, String> properties = new Hashtable< String, String>();
+        properties.put("foo.bar", "com.adobe.granite.foo.Bar");
+        ConfigurationHandler.write(out, properties);
+        String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+        Assert.assertEquals("foo.bar=\"com.adobe.granite.foo.Bar\"\r\n", entry);
+    }
+       
+    @Test
+    public void test_readArray() throws IOException {
+        String entry = "service.pid=[ \\\r\n  \"foo\", \\\r\n  \"bar\", \\\r\n  ]\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertArrayEquals(new String [] {"foo", "bar"}, (String [])dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readEmptyCollection() throws IOException {
+        String entry = "service.pid=( \\\r\n)\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals(new ArrayList(), (ArrayList)dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readCollection() throws IOException {
+        String entry = "service.pid=( \\\r\n  \"foo\", \\\r\n  \"bar\", \\\r\n)\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        List list = new ArrayList<String>(){{
+            add("foo");
+            add("bar");
+        }};
+        Assert.assertEquals(list, (ArrayList)dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readSimpleString() throws IOException {
+        String entry = "service.pid=\"com.adobe.granite.foo.Bar\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals( "com.adobe.granite.foo.Bar", dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readSimpleStrings() throws IOException {
+        String entry = "service.pid=\"com.adobe.granite.foo.Bar\"\r\nfoo.bar=\"com.adobe.granite.foo.Baz\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(2, dictionary.size());
+        Assert.assertEquals( "com.adobe.granite.foo.Bar", dictionary.get(SERVICE_PID));
+        Assert.assertNotNull(dictionary.get("foo.bar"));
+    }
+    
+    @Test
+    public void test_readInteger() throws IOException {
+        String entry = "service.pid=I\"1000\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals( 1000, dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readLong() throws IOException {
+        String entry = "service.pid=L\"1000\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals( 1000L, dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readFloat() throws IOException {
+        String entry = "service.pid=F\"1080452710\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals( 3.6f, dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readDouble() throws IOException {
+        String entry = "service.pid=D\"4615288898129284301\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals( 3.6d, dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readByte() throws IOException {
+        String entry = "service.pid=X\"10\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals((byte)10 , dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readShort() throws IOException {
+        String entry = "service.pid=S\"10\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals((short)10 , dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readChar() throws IOException {
+        String entry = "service.pid=C\"c\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals('c' , dictionary.get(SERVICE_PID));
+    }
+    
+    @Test
+    public void test_readBoolean() throws IOException {
+        String entry = "service.pid=B\"true\"\r\n";
+        InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+        Dictionary dictionary = ConfigurationHandler.read(stream);
+        Assert.assertEquals(1, dictionary.size());
+        Assert.assertEquals(true , dictionary.get(SERVICE_PID));
     }
 }
+  

Modified: felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java (original)
+++ felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java Fri Oct 21 15:18:20 2016
@@ -28,10 +28,11 @@ import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.felix.cm.MockBundleContext;
 import org.apache.felix.cm.MockLogService;
+import org.apache.felix.cm.MockNotCachablePersistenceManager;
 import org.apache.felix.cm.MockPersistenceManager;
+import org.apache.felix.cm.PersistenceManager;
 import org.mockito.Mockito;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -41,10 +42,8 @@ import org.osgi.service.cm.Configuration
 import org.osgi.service.cm.SynchronousConfigurationListener;
 import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
-
 import junit.framework.TestCase;
 
-
 public class ConfigurationManagerTest extends TestCase
 {
 
@@ -73,6 +72,84 @@ public class ConfigurationManagerTest ex
         super.tearDown();
     }
 
+    public void test_listConfigurations_cached() throws Exception
+    {
+        String pid = "testDefaultPersistenceManager";
+        ConfigurationManager configMgr = new ConfigurationManager();
+        setServiceTrackerField( configMgr, "persistenceManagerTracker" );
+        
+        Field field = configMgr.getClass().getDeclaredField( "persistenceManagers" );
+        field.setAccessible( true );
+        CachingPersistenceManagerProxy[] persistenceManagers = new CachingPersistenceManagerProxy [1];
+        PersistenceManager pm =new MockPersistenceManager(); 
+        Dictionary dictionary = new Hashtable();
+        dictionary.put( "property1", "value1" );
+        dictionary.put( Constants.SERVICE_PID, pid );
+        pm.store( pid, dictionary );
+
+        persistenceManagers[0] = new CachingPersistenceManagerProxy(pm);
+        field.set(configMgr, persistenceManagers);
+        
+        ConfigurationImpl[] conf = configMgr.listConfigurations(new ConfigurationAdminImpl(configMgr, null), null);
+        
+        assertEquals(1, conf.length);
+        assertEquals(2, conf[0].getProperties(true).size());
+        
+        Field configurations = configMgr.getClass().getDeclaredField( "configurations" );
+        configurations.setAccessible( true );
+        HashMap<String, ConfigurationImpl> configurationsMap = new HashMap<String, ConfigurationImpl>();
+        configurationsMap.put(pid, conf[0]);
+        configurations.set(configMgr, configurationsMap);
+        
+        dictionary = new Hashtable();
+        dictionary.put( "property1", "value2" );
+        pid = "testDefaultPersistenceManager";
+        dictionary.put( Constants.SERVICE_PID, pid );
+        pm.store( pid, dictionary );
+ 
+        conf = configMgr.listConfigurations(new ConfigurationAdminImpl(configMgr, null), null);
+        assertEquals(1, conf.length);
+        assertEquals(2, conf[0].getProperties(true).size());
+    }    
+    
+    public void test_listConfigurations_notcached() throws Exception
+    {
+        String pid = "testDefaultPersistenceManager";         
+        ConfigurationManager configMgr = new ConfigurationManager();
+        setServiceTrackerField( configMgr, "persistenceManagerTracker" );
+        
+        Field field = configMgr.getClass().getDeclaredField( "persistenceManagers" );
+        field.setAccessible( true );
+        CachingPersistenceManagerProxy[] persistenceManagers = new CachingPersistenceManagerProxy[1];
+        PersistenceManager pm =new MockNotCachablePersistenceManager(); 
+        Dictionary dictionary = new Hashtable();
+        dictionary.put( "property1", "value1" );
+        dictionary.put( Constants.SERVICE_PID, pid );
+        pm.store( pid, dictionary );
+
+        persistenceManagers[0] = new CachingPersistenceManagerProxy(pm);
+        field.set(configMgr, persistenceManagers);
+        
+        ConfigurationImpl[] conf = configMgr.listConfigurations(new ConfigurationAdminImpl(configMgr, null), null);
+        
+        assertEquals(1, conf.length);
+        assertEquals(2, conf[0].getProperties(true).size());
+        
+        Field configurations = configMgr.getClass().getDeclaredField( "configurations" );
+        configurations.setAccessible( true );
+        HashMap<String, ConfigurationImpl> configurationsMap = new HashMap<String, ConfigurationImpl>();
+        configurationsMap.put(pid, conf[0]);
+        configurations.set(configMgr, configurationsMap);
+        
+        dictionary = new Hashtable();
+        pid = "testDefaultPersistenceManager";
+        dictionary.put( Constants.SERVICE_PID, pid );
+        pm.store( pid, dictionary );
+ 
+        conf = configMgr.listConfigurations(new ConfigurationAdminImpl(configMgr, null), null);
+        assertEquals(1, conf.length);
+        assertEquals(1, conf[0].getProperties(true).size());
+    }
 
     public void testLogNoLogService()
     {
@@ -214,6 +291,7 @@ public class ConfigurationManagerTest ex
 
         SynchronousConfigurationListener syncListener1 = new SynchronousConfigurationListener()
         {
+            @Override
             public void configurationEvent(ConfigurationEvent event)
             {
                 result.add("L1");
@@ -221,6 +299,7 @@ public class ConfigurationManagerTest ex
         };
         SynchronousConfigurationListener syncListener2 = new SynchronousConfigurationListener()
         {
+            @Override
             public void configurationEvent(ConfigurationEvent event)
             {
                 result.add("L2");
@@ -228,6 +307,7 @@ public class ConfigurationManagerTest ex
         };
         SynchronousConfigurationListener syncListener3 = new SynchronousConfigurationListener()
         {
+            @Override
             public void configurationEvent(ConfigurationEvent event)
             {
                 result.add("L3");
@@ -272,7 +352,7 @@ public class ConfigurationManagerTest ex
         utField.setAccessible( true );
         utField.set( configMgr, new UpdateThread( configMgr, null, "Test updater" ));
 
-        Dictionary<String, String> props = new Hashtable<String, String>();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put( Constants.SERVICE_PID, "org.acme.testpid" );
         ConfigurationImpl config = new ConfigurationImpl( configMgr, new MockPersistenceManager(), props );
         configMgr.updated( config, true );

Modified: felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java?rev=1766046&r1=1766045&r2=1766046&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java (original)
+++ felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java Fri Oct 21 15:18:20 2016
@@ -222,36 +222,42 @@ public class RankingComparatorTest exten
         }
 
 
+        @Override
         public Object getProperty( String key )
         {
             return props.get( key );
         }
 
 
+        @Override
         public String[] getPropertyKeys()
         {
             return props.keySet().toArray( new String[props.size()] );
         }
 
 
+        @Override
         public Bundle getBundle()
         {
             return null;
         }
 
 
+        @Override
         public Bundle[] getUsingBundles()
         {
             return null;
         }
 
 
+        @Override
         public boolean isAssignableTo( Bundle bundle, String className )
         {
             return false;
         }
 
 
+        @Override
         public int compareTo( Object reference )
         {
             return 0;