From 2a32ba2e7438533d2387ecff88934a47091a6dbb Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 11 Sep 2017 09:01:32 +0200 Subject: [PATCH] [KARAF-5358] Upgrade to Felix Utils 1.10.2 and FileInstall 3.6.2 --- .../internal/service/FeatureConfigInstaller.java | 7 +++---- .../java/org/apache/karaf/features/AppendTest.java | 4 +++- pom.xml | 4 ++-- .../java/org/apache/karaf/profile/impl/Profiles.java | 12 +++++++++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java index 694427e82b6..4ebd04385d8 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java @@ -290,15 +290,14 @@ private void updateExistingConfig(TypedProperties props, boolean append, File cf for (String key : props.keySet()) { if (!isInternalKey(key)) { List comments = props.getComments(key); - List value = props.getRaw(key); - Object writeValue = (value.size() == 1) ? value.get(0) : value; + Object value = props.get(key); if (!properties.containsKey(key)) { - properties.put(key, comments, writeValue); + properties.put(key, comments, value); } else if (!append) { if (comments.isEmpty()) { comments = properties.getComments(key); } - properties.put(key, comments, writeValue); + properties.put(key, comments, value); } } } diff --git a/features/core/src/test/java/org/apache/karaf/features/AppendTest.java b/features/core/src/test/java/org/apache/karaf/features/AppendTest.java index 434cbc9c6c6..4cb6c83fa53 100644 --- a/features/core/src/test/java/org/apache/karaf/features/AppendTest.java +++ b/features/core/src/test/java/org/apache/karaf/features/AppendTest.java @@ -100,7 +100,9 @@ private void testAppendInternal(boolean cfgFileExists) throws IOException, Inval assertEquals("data/pax-web-jsp", captured.getValue().get("javax.servlet.context.tempdir")); Properties props = new Properties(); props.load(new FileInputStream(cfgFile)); - assertEquals("data/pax-web-jsp", props.getProperty("javax.servlet.context.tempdir")); + String v = props.getProperty("javax.servlet.context.tempdir"); + assertTrue("${karaf.data}/pax-web-jsp".equals(v) || "data/pax-web-jsp".equals(v)); +// assertEquals("${karaf.data}/pax-web-jsp", props.getProperty("javax.servlet.context.tempdir")); } private Configuration expectConfig(ConfigurationAdmin admin, Hashtable original) diff --git a/pom.xml b/pom.xml index 8fa9035138d..38a1084152f 100644 --- a/pom.xml +++ b/pom.xml @@ -190,7 +190,7 @@ 1.8.14 0.1.0 1.0.2 - 3.6.0 + 3.6.2 5.6.6 2.6.0 1.0.6 @@ -198,7 +198,7 @@ 0.1.6 1.0.4 3.3.0 - 1.10.0 + 1.10.2 4.3.4 3.1.2 1.1.2 diff --git a/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java b/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java index c9ded5c7880..9fbfdcc29bb 100644 --- a/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java +++ b/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java @@ -153,6 +153,7 @@ public static Profile getEffective(final Profile profile, assertNotNull(profile, "resolvers is null"); final Map originals = new HashMap<>(); + final Map originals2 = new HashMap<>(); for (Map.Entry entry : profile.getFileConfigurations().entrySet()) { if (entry.getKey().endsWith(Profile.PROPERTIES_SUFFIX)) { try { @@ -160,6 +161,9 @@ public static Profile getEffective(final Profile profile, TypedProperties props = new TypedProperties(false); props.load(new ByteArrayInputStream(entry.getValue())); originals.put(key, props); + props = new TypedProperties(false); + props.load(new ByteArrayInputStream(entry.getValue())); + originals2.put(key, props); } catch (IOException e) { throw new IllegalArgumentException("Can not load properties for " + entry.getKey()); } @@ -194,9 +198,11 @@ public static Profile getEffective(final Profile profile, // Force computation while preserving layout ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); - for (Map.Entry cfg : originals.entrySet()) { - TypedProperties original = cfg.getValue(); - builder.addFileConfiguration(cfg.getKey() + Profile.PROPERTIES_SUFFIX, Utils.toBytes(original)); + for (String cfg : originals.keySet()) { + TypedProperties original = originals.get(cfg); + TypedProperties original2 = originals2.get(cfg); + original2.putAll(original); + builder.addFileConfiguration(cfg + Profile.PROPERTIES_SUFFIX, Utils.toBytes(original2)); } // Compute the new profile return builder.getProfile();