You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/01/10 14:15:54 UTC
[karaf] branch karaf-4.1.x updated: [KARAF-6080] Avoid duplicate configuration when cfg file already exist while installing a feature Author: J. Brébec
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.1.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.1.x by this push:
new 145d611 [KARAF-6080] Avoid duplicate configuration when cfg file already exist while installing a feature Author: J. Brébec
145d611 is described below
commit 145d6111127fe62e8f18b848979905423e1183cc
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Thu Jan 10 09:10:43 2019 +0100
[KARAF-6080] Avoid duplicate configuration when cfg file already exist while installing a feature
Author: J. Brébec
---
.../internal/service/FeatureConfigInstaller.java | 36 +++++++++++++---------
1 file changed, 21 insertions(+), 15 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 b2ecefa..7567893 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
@@ -105,25 +105,31 @@ public class FeatureConfigInstaller {
String[] pid = parsePid(config.getName());
Configuration cfg = findExistingConfiguration(configAdmin, pid[0], pid[1]);
if (cfg == null) {
- Dictionary<String, String> cfgProps = convertToDict(props);
- cfg = createConfiguration(configAdmin, pid[0], pid[1]);
- String key = createConfigurationKey(pid[0], pid[1]);
- cfgProps.put(CONFIG_KEY, key);
- props.put(CONFIG_KEY, key);
- if (storage != null && configCfgStore) {
- File cfgFile;
- if (pid[1] != null) {
- cfgFile = new File(storage, pid[0] + "-" + pid[1] + ".cfg");
+ File cfgFile = null;
+ if (storage != null && configCfgStore) {
+ if (pid[1] != null) {
+ cfgFile = new File(storage, pid[0] + "-" + pid[1] + ".cfg");
} else {
cfgFile = new File(storage, pid[0] + ".cfg");
}
- cfgProps.put(FILEINSTALL_FILE_NAME, cfgFile.getAbsoluteFile().toURI().toString());
}
- cfg.update(cfgProps);
- try {
- updateStorage(pid[0], pid[1], props, false);
- } catch (Exception e) {
- LOGGER.warn("Can't update cfg file", e);
+ if (!cfgFile.exists()) {
+ Dictionary<String, String> cfgProps = convertToDict(props);
+ cfg = createConfiguration(configAdmin, pid[0], pid[1]);
+ String key = createConfigurationKey(pid[0], pid[1]);
+ cfgProps.put(CONFIG_KEY, key);
+ props.put(CONFIG_KEY, key);
+ if (storage != null && configCfgStore) {
+ cfgProps.put(FILEINSTALL_FILE_NAME, cfgFile.getAbsoluteFile().toURI().toString());
+ }
+ cfg.update(cfgProps);
+ try {
+ updateStorage(pid[0], pid[1], props, false);
+ } catch (Exception e) {
+ LOGGER.warn("Can't update cfg file", e);
+ }
+ } else {
+ LOGGER.info("Skipping configuration {} - file already exists", cfgFile);
}
} else if (config.isAppend()) {
boolean update = false;