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 2021/05/08 13:36:20 UTC
[karaf] branch main updated: [KARAF-7097] Fix json config array
comparison
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/main by this push:
new e8cf789 [KARAF-7097] Fix json config array comparison
new f8b93a1 Merge pull request #1375 from jbonofre/KARAF-7097
e8cf789 is described below
commit e8cf789646c01cfbdf26bad03567df5171609f03
Author: jbonofre <jb...@apache.org>
AuthorDate: Sat May 8 07:45:28 2021 +0200
[KARAF-7097] Fix json config array comparison
---
.../karaf/config/core/impl/JsonConfigInstaller.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java b/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java
index 1d7560d..c80df7d 100644
--- a/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java
+++ b/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java
@@ -36,6 +36,7 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Arrays;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Objects;
@@ -82,8 +83,24 @@ public class JsonConfigInstaller implements ArtifactInstaller, ConfigurationList
old.remove(Constants.SERVICE_PID);
old.remove(ConfigurationAdmin.SERVICE_FACTORYPID);
}
- // KARAF-6998: Call equals on 'old' because 'properties' is an OrderDictionary with broken equals
- if (old == null || !old.equals(properties)) {
+ boolean updated = false;
+ if (old == null || old.size() != properties.size()) {
+ updated = true;
+ } else {
+ for (String key : old.keySet()) {
+ Object oldValue = old.get(key);
+ Object propertiesValue = properties.get(key);
+ if (oldValue instanceof Object[] && propertiesValue instanceof Object[]) {
+ updated = !Arrays.deepEquals((Object[]) oldValue, (Object[]) propertiesValue);
+ } else {
+ updated = !oldValue.equals(propertiesValue);
+ }
+ if (updated) {
+ break;
+ }
+ }
+ }
+ if (updated) {
properties.put(DirectoryWatcher.FILENAME, toConfigKey(artifact));
if (old == null) {
LOGGER.info("Creating configuration from {}", artifact.getName());