[ 
https://issues.apache.org/jira/browse/KARAF-5432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16220494#comment-16220494
 ] 

ASF GitHub Bot commented on KARAF-5432:
---------------------------------------

gnodet closed pull request #389: [KARAF-5432] Upgrade to Felix Utils 1.10.4 and 
FileInstall 3.6.4
URL: https://github.com/apache/karaf/pull/389
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/config/src/main/java/org/apache/karaf/config/command/UpdateCommand.java 
b/config/src/main/java/org/apache/karaf/config/command/UpdateCommand.java
index a908c8cd66..ff572a7d55 100644
--- a/config/src/main/java/org/apache/karaf/config/command/UpdateCommand.java
+++ b/config/src/main/java/org/apache/karaf/config/command/UpdateCommand.java
@@ -29,7 +29,7 @@
     protected Object doExecute() throws Exception {
         TypedProperties props = getEditedProps();
         if (props == null) {
-            System.err.println("No configuration is being edited--run the edit 
command first");
+            System.err.println("No configuration is being edited. Run the edit 
command first.");
             return null;
         }
 
diff --git 
a/config/src/main/java/org/apache/karaf/config/core/impl/ConfigRepositoryImpl.java
 
b/config/src/main/java/org/apache/karaf/config/core/impl/ConfigRepositoryImpl.java
index b2d05c8395..898c88c9e9 100644
--- 
a/config/src/main/java/org/apache/karaf/config/core/impl/ConfigRepositoryImpl.java
+++ 
b/config/src/main/java/org/apache/karaf/config/core/impl/ConfigRepositoryImpl.java
@@ -24,8 +24,10 @@
 import java.net.URL;
 import java.util.Dictionary;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.felix.utils.properties.TypedProperties;
 import org.apache.karaf.config.core.ConfigRepository;
@@ -55,19 +57,24 @@ public ConfigRepositoryImpl(ConfigurationAdmin configAdmin) 
{
     public void update(String pid, Map<String, Object> properties) throws 
IOException {
         try {
             LOGGER.trace("Updating configuration {}", pid);
-            Configuration cfg = configAdmin.getConfiguration(pid, null);
+            Configuration cfg = configAdmin.getConfiguration(pid, "?");
             Dictionary<String, Object> dict = cfg.getProperties();
             TypedProperties props = new TypedProperties();
             File file = getCfgFileFromProperties(dict);
             if (file != null) {
                 props.load(file);
                 props.putAll(properties);
+                props.keySet().retainAll(properties.keySet());
                 props.save(file);
                 props.clear();
                 props.load(file);
                 props.put(FILEINSTALL_FILE_NAME, file.toURI().toString());
             } else {
+                file = new File(System.getProperty("karaf.etc"), pid + ".cfg");
                 props.putAll(properties);
+                props.keySet().retainAll(properties.keySet());
+                props.save(file);
+                props.put(FILEINSTALL_FILE_NAME, file.toURI().toString());
             }
             cfg.update(new Hashtable<>(props));
         } catch (URISyntaxException e) {
@@ -146,7 +153,12 @@ public String createFactoryConfiguration(String 
factoryPid, Map<String, Object>
     @Override
     public String createFactoryConfiguration(String factoryPid, String alias, 
Map<String, Object> properties) throws IOException {
         Configuration config = 
configAdmin.createFactoryConfiguration(factoryPid, "?");
-        config.update(new Hashtable<>(properties));
+        TypedProperties props = new TypedProperties();
+        File file = File.createTempFile(factoryPid + "-", ".cfg", new 
File(System.getProperty("karaf.etc")));
+        props.putAll(properties);
+        props.save(file);
+        props.put(FILEINSTALL_FILE_NAME, file.toURI().toString());
+        config.update(new Hashtable<>(props));
         return config.getPid();
     }
 
diff --git a/itests/src/test/java/org/apache/karaf/itests/BundleTest.java 
b/itests/src/test/java/org/apache/karaf/itests/BundleTest.java
index 38b270fb52..2fd336d840 100644
--- a/itests/src/test/java/org/apache/karaf/itests/BundleTest.java
+++ b/itests/src/test/java/org/apache/karaf/itests/BundleTest.java
@@ -62,7 +62,7 @@ public void capabilitiesCommand() throws Exception {
         assertFalse(allCapabilitiesOutput.isEmpty());
         String jmxWhiteboardBundleCapabilitiesOutput = 
executeCommand("bundle:capabilities org.apache.aries.jmx.whiteboard", 
ADMIN_ROLES);
         System.out.println(jmxWhiteboardBundleCapabilitiesOutput);
-        
assertTrue(jmxWhiteboardBundleCapabilitiesOutput.contains("osgi.wiring.bundle; 
org.apache.aries.jmx.whiteboard 1.1.5 [UNUSED]"));
+        assertContains("osgi.wiring.bundle; org.apache.aries.jmx.whiteboard 
1.1.5 [UNUSED]", jmxWhiteboardBundleCapabilitiesOutput);
     }
 
     @Test
@@ -71,7 +71,7 @@ public void classesCommand() throws Exception {
         assertFalse(allClassesOutput.isEmpty());
         String jmxWhiteboardBundleClassesOutput = 
executeCommand("bundle:classes org.apache.aries.jmx.whiteboard", ADMIN_ROLES);
         System.out.println(jmxWhiteboardBundleClassesOutput);
-        
assertTrue(jmxWhiteboardBundleClassesOutput.contains("org/apache/aries/jmx/whiteboard/Activator$MBeanTracker.class"));
+        
assertContains("org/apache/aries/jmx/whiteboard/Activator$MBeanTracker.class", 
jmxWhiteboardBundleClassesOutput);
     }
 
     /**
@@ -94,14 +94,14 @@ public void findClassCommand() throws Exception {
     public void headersCommand() throws Exception {
         String headersOutput = executeCommand("bundle:headers 
org.apache.aries.jmx.whiteboard", ADMIN_ROLES);
         System.out.println(headersOutput);
-        assertTrue(headersOutput.contains("Bundle-Activator = 
org.apache.aries.jmx.whiteboard.Activator"));
+        assertContains("Bundle-Activator = 
org.apache.aries.jmx.whiteboard.Activator", headersOutput);
     }
 
     @Test
     public void infoCommand() throws Exception {
         String infoOutput = executeCommand("bundle:info 
org.apache.karaf.management.server", ADMIN_ROLES);
         System.out.println(infoOutput);
-        assertTrue(infoOutput.contains("This bundle starts the Karaf embedded 
MBean server"));
+        assertContains("This bundle starts the Karaf embedded MBean server", 
infoOutput);
     }
 
     @Test
diff --git 
a/itests/src/test/java/org/apache/karaf/itests/ssh/ConfigSshCommandSecurityTest.java
 
b/itests/src/test/java/org/apache/karaf/itests/ssh/ConfigSshCommandSecurityTest.java
index 2e012c91de..7d627be31c 100644
--- 
a/itests/src/test/java/org/apache/karaf/itests/ssh/ConfigSshCommandSecurityTest.java
+++ 
b/itests/src/test/java/org/apache/karaf/itests/ssh/ConfigSshCommandSecurityTest.java
@@ -66,27 +66,26 @@ private void testConfigEdits(String user, Result 
expectedEditResult, String pid,
         String result = assertCommand(user, "config:edit " + pid + "\n" +
                 "config:property-list\n" +
                 "config:cancel", Result.OK);
-        Assert.assertTrue("Result should contain 'x = yz': " + result, 
result.contains("x = yz"));
-        Assert.assertTrue("Result should contain 'a = b': " + result, 
result.contains("a = b"));
+        assertContains("a = b", result);
         String result2 = assertCommand(user, "config:edit " + pid + "\n" +
                 "config:property-delete a\n" +
                 "config:property-list\n" +
                 "config:update", Result.OK);
-        Assert.assertTrue("Result should contain 'x = yz': " + result2, 
result2.contains("x = yz"));
-        Assert.assertFalse("Result should contain 'a = b': " + result2, 
result2.contains("a = b"));
+        assertContains("x = yz", result2);
+        assertContainsNot("a = b", result2);
 
         if (isAdmin) {
             assertCommand(user, "config:delete " + pid, Result.OK);
             String result3 = assertCommand(user, "config:edit " + pid + "\n" +
                     "config:property-list", Result.OK);
-            Assert.assertFalse(result3.contains("x = yz"));
-            Assert.assertFalse(result3.contains("a = b"));
+            assertContainsNot("x = yz", result3);
+            assertContainsNot("a = b", result3);
         } else {
             assertCommand(user, "config:delete " + pid, Result.NOT_FOUND);
             String result3 = assertCommand(user, "config:edit " + pid + "\n" +
                     "config:property-list", Result.OK);
-            Assert.assertTrue("The delete command should have had no effect", 
result3.contains("x = yz"));
-            Assert.assertFalse(result3.contains("a = b"));
+            assertContains("x = yz", result3);
+            assertContainsNot("a = b", result3);
         }
     }
 
@@ -123,11 +122,11 @@ private void testConfigEditsNoSession(String user, Result 
expectedResult, String
         assertCommand(user, "config:property-append -p " + pid + " a.b.c 
.g.h", expectedResult);
 
         if (expectedResult == Result.OK) {
-            Assert.assertTrue(assertCommand(user, "config:property-list -p " + 
pid, Result.OK).contains("a.b.c = d.e.f.g.h"));
+            assertContains("a.b.c = d.e.f.g.h", assertCommand(user, 
"config:property-list -p " + pid, Result.OK));
         }
         assertCommand(user, "config:property-delete -p " + pid + " a.b.c", 
expectedResult);
         if (expectedResult == Result.OK) {
-            Assert.assertFalse(assertCommand(user, "config:property-list -p " 
+ pid, Result.OK).contains("a.b.c"));
+            assertContainsNot("a.b.c", assertCommand(user, 
"config:property-list -p " + pid, Result.OK));
         }
     }
 }
diff --git a/pom.xml b/pom.xml
index aa8a234ed8..eeaf438e72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -189,7 +189,7 @@
         <felix.configadmin.version>1.8.16</felix.configadmin.version>
         <felix.connect.version>0.1.0</felix.connect.version>
         <felix.coordinator.version>1.0.2</felix.coordinator.version>
-        <felix.fileinstall.version>3.6.2</felix.fileinstall.version>
+        <felix.fileinstall.version>3.6.4</felix.fileinstall.version>
         <felix.framework.version>5.6.8</felix.framework.version>
         
<felix.framework.security.version>2.6.0</felix.framework.security.version>
         <felix.gogo.runtime.version>1.0.10</felix.gogo.runtime.version>
@@ -197,7 +197,7 @@
         <felix.httplite.version>0.1.6</felix.httplite.version>
         <felix.inventory.version>1.0.4</felix.inventory.version>
         <felix.plugin.version>3.3.0</felix.plugin.version>
-        <felix.utils.version>1.10.2</felix.utils.version>
+        <felix.utils.version>1.10.4</felix.utils.version>
         <felix.webconsole.version>4.3.4</felix.webconsole.version>
         <felix.webconsole.api.version>3.1.2</felix.webconsole.api.version>
         <felix.metatype.version>1.1.4</felix.metatype.version>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Upgrade to Felix Utils 1.10.4 and FileInstall 3.6.4
> ---------------------------------------------------
>
>                 Key: KARAF-5432
>                 URL: https://issues.apache.org/jira/browse/KARAF-5432
>             Project: Karaf
>          Issue Type: Dependency upgrade
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>             Fix For: 4.2.0
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to