asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: [NO ISSUE] Take defensive copy of array options
Date Sun, 04 Mar 2018 06:22:18 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master e8b5269d4 -> 4d1d0d157


[NO ISSUE] Take defensive copy of array options

Change-Id: I6085e7fc392e8bac960c478bf1500b077528c4ea
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2451
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/4d1d0d15
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/4d1d0d15
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/4d1d0d15

Branch: refs/heads/master
Commit: 4d1d0d157f5799b02081fa00e50ce90d31291757
Parents: e8b5269
Author: Michael Blow <mblow@apache.org>
Authored: Sat Mar 3 12:46:09 2018 -0500
Committer: Michael Blow <mblow@apache.org>
Committed: Sat Mar 3 22:21:58 2018 -0800

----------------------------------------------------------------------
 .../hyracks/control/common/config/ConfigManager.java  | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4d1d0d15/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java
index baff800..9564922 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/config/ConfigManager.java
@@ -20,6 +20,7 @@ package org.apache.hyracks.control.common.config;
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.lang.reflect.Array;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -40,6 +41,7 @@ import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 import org.apache.commons.collections4.map.CompositeMap;
@@ -491,7 +493,17 @@ public class ConfigManager implements IConfigManager, Serializable {
     }
 
     public void set(String nodeId, IOption option, Object value) {
-        invokeSetters(option, value, nodeId);
+        invokeSetters(option, copyIfArray(value), nodeId);
+    }
+
+    private Object copyIfArray(Object orig) {
+        if (orig == null || !orig.getClass().isArray()) {
+            return orig;
+        }
+        int arrayLength = Array.getLength(orig);
+        Object copy = Array.newInstance(orig.getClass().getComponentType(), arrayLength);
+        IntStream.range(0, arrayLength).forEach(i -> Array.set(copy, i, Array.get(orig,
i)));
+        return copy;
     }
 
     public Object get(IOption option) {


Mime
View raw message