This is an automated email from the ASF dual-hosted git repository.

shishkovilja pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new ba466919b5a IGNITE-29155 Fix sensitive data exposure and cyclic 
reference handling in ConfigurationView (#13726)
ba466919b5a is described below

commit ba466919b5af202b025e80e55d6b3da4fad1c38e
Author: Ilya Shishkov <[email protected]>
AuthorDate: Tue Oct 27 08:41:34 2026 +0300

    IGNITE-29155 Fix sensitive data exposure and cyclic reference handling in 
ConfigurationView (#13726)
---
 docs/_docs/monitoring-metrics/system-views.adoc    |   1 +
 .../internal/systemview/SensitiveProperty.java     |  35 +++++
 .../org/apache/ignite/ssl/SslContextFactory.java   |   3 +
 .../configuration/ConnectorConfiguration.java      |   2 +
 .../systemview/IgniteConfigurationIterable.java    | 153 ++++++++++++++++-----
 .../plugin/security/SecurityCredentials.java       |   2 +
 .../spi/checkpoint/jdbc/JdbcCheckpointSpi.java     |   2 +
 .../encryption/keystore/KeystoreEncryptionSpi.java |   2 +
 .../metric/SystemViewConfigurationTest.java        | 118 ++++++++++++++++
 9 files changed, 285 insertions(+), 33 deletions(-)

diff --git a/docs/_docs/monitoring-metrics/system-views.adoc 
b/docs/_docs/monitoring-metrics/system-views.adoc
index b17b6d78ebc..4907ba1bd9d 100644
--- a/docs/_docs/monitoring-metrics/system-views.adoc
+++ b/docs/_docs/monitoring-metrics/system-views.adoc
@@ -375,6 +375,7 @@ The NODE_ATTRIBUTES view contains the attributes of all 
nodes.
 
 
 The CONFIGURATION view contains the configuration properties of node.
+Sensitive properties (passwords, secret keys, etc.) are not exposed.
 
 [{table_opts}]
 |===
diff --git 
a/modules/commons/src/main/java/org/apache/ignite/internal/systemview/SensitiveProperty.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/systemview/SensitiveProperty.java
new file mode 100644
index 00000000000..9172e3f78bf
--- /dev/null
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/systemview/SensitiveProperty.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.systemview;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks a getter of a sensitive configuration property (password, secret key, 
etc.) that must not be exposed
+ * in the configuration system view. Doesn't affect {@code toString()} output.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface SensitiveProperty {
+    // No-op.
+}
diff --git 
a/modules/commons/src/main/java/org/apache/ignite/ssl/SslContextFactory.java 
b/modules/commons/src/main/java/org/apache/ignite/ssl/SslContextFactory.java
index af7d140b01f..e060dcc241b 100644
--- a/modules/commons/src/main/java/org/apache/ignite/ssl/SslContextFactory.java
+++ b/modules/commons/src/main/java/org/apache/ignite/ssl/SslContextFactory.java
@@ -34,6 +34,7 @@ import javax.net.ssl.SSLException;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 import javax.net.ssl.X509TrustManager;
+import org.apache.ignite.internal.systemview.SensitiveProperty;
 import org.apache.ignite.internal.util.typedef.internal.A;
 
 /**
@@ -177,6 +178,7 @@ public class SslContextFactory extends 
AbstractSslContextFactory {
      *
      * @return Key store password.
      */
+    @SensitiveProperty
     public char[] getKeyStorePassword() {
         return keyStorePwd;
     }
@@ -217,6 +219,7 @@ public class SslContextFactory extends 
AbstractSslContextFactory {
      *
      * @return Trust store password.
      */
+    @SensitiveProperty
     public char[] getTrustStorePassword() {
         return trustStorePwd;
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
 
b/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
index 238f6ce8c48..8d85d16f39d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
@@ -21,6 +21,7 @@ import java.net.Socket;
 import javax.cache.configuration.Factory;
 import javax.net.ssl.SSLContext;
 import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.internal.systemview.SensitiveProperty;
 import org.apache.ignite.internal.util.nio.GridNioServer;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -212,6 +213,7 @@ public class ConnectorConfiguration {
      * @see IgniteSystemProperties#IGNITE_JETTY_HOST
      * @see IgniteSystemProperties#IGNITE_JETTY_PORT
      */
+    @SensitiveProperty
     @Nullable public String getSecretKey() {
         return secretKey;
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/IgniteConfigurationIterable.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/IgniteConfigurationIterable.java
index 3eb61926f42..4789bac7813 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/IgniteConfigurationIterable.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/IgniteConfigurationIterable.java
@@ -33,11 +33,13 @@ import java.util.TreeMap;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.lang.GridTuple3;
+import org.apache.ignite.internal.systemview.SensitiveProperty;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T3;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.systemview.view.ConfigurationView;
+import org.jetbrains.annotations.Nullable;
 import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_CONFIGURATION_VIEW_PACKAGES;
 import static 
org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName;
 import static org.apache.ignite.internal.util.IgniteUtils.IGNITE_PKG;
@@ -45,17 +47,24 @@ import static 
org.apache.ignite.internal.util.IgniteUtils.IGNITE_PKG;
 /**
  * Responsibility of this class it to recursively iterate {@link 
IgniteConfiguration} object
  * and expose all properties in form of String pairs.
+ * {@link SensitiveProperty} and {@code char[]} properties are never exposed.
+ * Cyclic references and {@code null} array elements are not iterated.
  */
 public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView> {
+    /** Properties of classes: names and getters. */
+    private static final ClassValue<Map<String, Method>> PROPS = new 
ClassValue<>() {
+        @Override protected Map<String, Method> computeValue(Class<?> cls) {
+            return props(cls);
+        }
+    };
+
     /** Packages to expose objects from. */
     private final List<String> pkgs;
 
-    /** Iterators queue. */
-    private final Queue<GridTuple3<Object, Iterator<Map.Entry<String, 
Method>>, String>> iters = new LinkedList<>();
+    /** Configuration to iterate. */
+    private final IgniteConfiguration cfg;
 
-    /**
-     * @param cfg Configuration to iterate.
-     */
+    /** @param cfg Configuration to iterate. */
     public IgniteConfigurationIterable(IgniteConfiguration cfg) {
         String pkgsProp = 
IgniteSystemProperties.getString(IGNITE_CONFIGURATION_VIEW_PACKAGES);
 
@@ -66,13 +75,30 @@ public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView>
 
         pkgs.add(IGNITE_PKG);
 
-        addToQueue(cfg, "");
+        this.cfg = cfg;
     }
 
     /** {@inheritDoc} */
     @Override public Iterator<ConfigurationView> iterator() {
-        return new Iterator<ConfigurationView>() {
-            private ConfigurationView next;
+        return F.iterator(rawIterator(), t -> {
+            Object val = t.get2();
+
+            return new ConfigurationView(
+                t.get1(),
+                val != null && val.getClass().isArray()
+                    ? S.arrayToString(val)
+                    : U.toStringSafe(val));
+        }, true);
+    }
+
+    /** @return Iterator of configuration properties. */
+    public Iterator<T3<String, Object, Class<?>>> rawIterator() {
+        Queue<Node> iters = new LinkedList<>();
+
+        iters.add(new Node(cfg, "", null));
+
+        return new Iterator<>() {
+            private T3<String, Object, Class<?>> next;
 
             /** {@inheritDoc} */
             @Override public boolean hasNext() {
@@ -85,31 +111,28 @@ public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView>
                 if (next != null)
                     return;
 
-                while (!iters.isEmpty() && !iters.peek().get2().hasNext())
+                while (!iters.isEmpty() && !iters.peek().props.hasNext())
                     iters.remove();
 
                 if (!iters.isEmpty()) {
-                    GridTuple3<Object, Iterator<Map.Entry<String, Method>>, 
String> curr = iters.peek();
+                    Node curr = iters.peek();
 
                     try {
-                        Map.Entry<String, Method> prop = curr.get2().next();
+                        Map.Entry<String, Method> prop = curr.props.next();
 
-                        String name = curr.get3().isEmpty() ? prop.getKey() : 
metricName(curr.get3(), prop.getKey());
+                        String name = curr.prefix.isEmpty() ? prop.getKey() : 
metricName(curr.prefix, prop.getKey());
 
-                        Object val = prop.getValue().invoke(curr.get1());
+                        Method getter = prop.getValue();
 
-                        if (addToQueue(val, name)) {
+                        Object val = getter.invoke(curr.obj);
+
+                        if (addToQueue(iters, val, name, curr)) {
                             advance();
 
                             return;
                         }
 
-                        next = new ConfigurationView(
-                            name,
-                            val != null && val.getClass().isArray()
-                                ? S.arrayToString(val)
-                                : U.toStringSafe(val)
-                        );
+                        next = new T3<>(name, val, getter.getReturnType());
                     }
                     catch (IllegalAccessException | InvocationTargetException 
e) {
                         throw new IgniteException(e);
@@ -118,11 +141,11 @@ public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView>
             }
 
             /** {@inheritDoc} */
-            @Override public ConfigurationView next() {
+            @Override public T3<String, Object, Class<?>> next() {
                 if (next == null)
                     advance();
 
-                ConfigurationView next0 = next;
+                T3<String, Object, Class<?>> next0 = next;
 
                 if (next0 == null)
                     throw new NoSuchElementException();
@@ -136,11 +159,11 @@ public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView>
 
     /**
      * If {@code val} is configuration bean that must be recursively exposed 
by the view then
-     * it will be added to the {@link #iters} queue.
+     * it will be added to the {@code iters} queue.
      *
-     * @return {@code True} if {@code val} was added to {@link #iters} queue, 
{@code false} otherwise.
+     * @return {@code True} if {@code val} was added to {@code iters} queue, 
{@code false} otherwise.
      */
-    private boolean addToQueue(Object val, String prefix) {
+    private boolean addToQueue(Queue<Node> iters, Object val, String prefix, 
Node parent) {
         if (val == null || val.getClass().isEnum())
             return false;
 
@@ -157,25 +180,34 @@ public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView>
         if (isArr) {
             int length = Array.getLength(val);
 
-            if (length == 0)
-                return false;
+            boolean added = false;
 
             for (int i = 0; i < length; i++) {
                 Object el = Array.get(val, i);
-                iters.add(F.t(el, props(el.getClass()), prefix + '[' + i + 
']'));
+
+                if (el != null && !Node.contains(parent, el)) {
+                    iters.add(new Node(el, prefix + '[' + i + ']', parent));
+
+                    added = true;
+                }
             }
+
+            return added;
         }
 
-        iters.add(F.t(val, props(val.getClass()), prefix));
+        if (Node.contains(parent, val))
+            return false;
+
+        iters.add(new Node(val, prefix, parent));
 
         return true;
     }
 
     /**
      * @param cls Class to find properties.
-     * @return Iterator of object properties.
+     * @return Non-sensitive sorted properties.
      */
-    private Iterator<Map.Entry<String, Method>> props(Class<?> cls) {
+    private static Map<String, Method> props(Class<?> cls) {
         Map<String, Method> props = new TreeMap<>(); // TreeMap to keep 
properties sorted.
 
         for (; cls != Object.class; cls = cls.getSuperclass()) {
@@ -194,7 +226,28 @@ public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView>
             }
         }
 
-        return props.entrySet().iterator();
+        props.values().removeIf(IgniteConfigurationIterable::isSensitive);
+
+        return props;
+    }
+
+    /**
+     * Annotation is also looked up in superclasses, as the getter can be 
overridden. Interfaces are not checked.
+     *
+     * @return {@code True} if property is marked as {@link SensitiveProperty} 
or has {@code char[]} type.
+     */
+    private static boolean isSensitive(Method getter) {
+        if (getter.getReturnType() == char[].class)
+            return true;
+
+        for (Class<?> cls = getter.getDeclaringClass(); cls != null; cls = 
cls.getSuperclass()) {
+            Method mtd = methodOrNull(cls, getter.getName());
+
+            if (mtd != null && 
mtd.isAnnotationPresent(SensitiveProperty.class))
+                return true;
+        }
+
+        return false;
     }
 
     /**
@@ -220,4 +273,38 @@ public class IgniteConfigurationIterable implements 
Iterable<ConfigurationView>
 
         return false;
     }
+
+    /** Queue entry: object to iterate. */
+    private static class Node {
+        /** */
+        private final Object obj;
+
+        /** */
+        private final Iterator<Map.Entry<String, Method>> props;
+
+        /** Name prefix of object properties. */
+        private final String prefix;
+
+        /** Parent entry, {@code null} for the root. */
+        @Nullable private final Node parent;
+
+        /** */
+        private Node(Object obj, String prefix, @Nullable Node parent) {
+            this.obj = obj;
+            this.prefix = prefix;
+            this.parent = parent;
+
+            props = PROPS.get(obj.getClass()).entrySet().iterator();
+        }
+
+        /** @return {@code True} if {@code obj} is the object of {@code node} 
or of any of its parents. */
+        private static boolean contains(@Nullable Node node, Object obj) {
+            for (; node != null; node = node.parent) {
+                if (node.obj == obj)
+                    return true;
+            }
+
+            return false;
+        }
+    }
 }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityCredentials.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityCredentials.java
index b046a3e8b6b..2529456de5b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityCredentials.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityCredentials.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Objects;
+import org.apache.ignite.internal.systemview.SensitiveProperty;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -120,6 +121,7 @@ public class SecurityCredentials implements Externalizable {
      *
      * @return Password.
      */
+    @SensitiveProperty
     public Object getPassword() {
         return password;
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpi.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpi.java
index adc00a89073..a17ed0ea60c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpi.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpi.java
@@ -26,6 +26,7 @@ import java.sql.Time;
 import java.text.MessageFormat;
 import javax.sql.DataSource;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.systemview.SensitiveProperty;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.resources.LoggerResource;
@@ -275,6 +276,7 @@ public class JdbcCheckpointSpi extends IgniteSpiAdapter 
implements CheckpointSpi
      *
      * @return Password for checkpoint jdbc.
      */
+    @SensitiveProperty
     public String getPwd() {
         return pwd;
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/encryption/keystore/KeystoreEncryptionSpi.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/encryption/keystore/KeystoreEncryptionSpi.java
index 1f2e1b244e9..b6e3b58df99 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/encryption/keystore/KeystoreEncryptionSpi.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/encryption/keystore/KeystoreEncryptionSpi.java
@@ -44,6 +44,7 @@ import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.systemview.SensitiveProperty;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.resources.LoggerResource;
@@ -448,6 +449,7 @@ public class KeystoreEncryptionSpi extends IgniteSpiAdapter 
implements Encryptio
      *
      * @return Key store password.
      */
+    @SensitiveProperty
     public char[] getKeyStorePwd() {
         return keyStorePwd;
     }
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewConfigurationTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewConfigurationTest.java
index 35574e996aa..8df733d80ac 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewConfigurationTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewConfigurationTest.java
@@ -20,10 +20,14 @@ package org.apache.ignite.internal.metric;
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.DataRegionConfiguration;
 import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
+import 
org.apache.ignite.internal.managers.systemview.IgniteConfigurationIterable;
+import org.apache.ignite.internal.systemview.SensitiveProperty;
+import org.apache.ignite.plugin.PluginConfiguration;
 import org.apache.ignite.spi.systemview.view.ConfigurationView;
 import org.apache.ignite.spi.systemview.view.SystemView;
 import org.junit.Test;
@@ -31,6 +35,7 @@ import org.junit.Test;
 import static org.apache.ignite.events.EventType.EVT_CONSISTENCY_VIOLATION;
 import static org.apache.ignite.internal.IgniteKernal.CFG_VIEW;
 import static org.apache.ignite.internal.util.IgniteUtils.MB;
+import static org.apache.ignite.testframework.GridTestUtils.sslFactory;
 
 /** Tests for {@link SystemView} for configuration. */
 public class SystemViewConfigurationTest extends SystemViewAbstractTest {
@@ -79,4 +84,117 @@ public class SystemViewConfigurationTest extends 
SystemViewAbstractTest {
             assertEquals("[" + EVT_CONSISTENCY_VIOLATION + ']', 
viewContent.get("IncludeEventTypes"));
         }
     }
+
+    /** Tests that sensitive properties are excluded even if {@code 
toString()} includes sensitive data (default). */
+    @Test
+    public void testSensitivePropertiesExcluded() throws Exception {
+        String secretKey = "my-secret-key";
+
+        Map<String, String> viewContent = viewContent(getConfiguration()
+            .setSslContextFactory(sslFactory())
+            .setConnectorConfiguration(new 
TestConnectorConfiguration().setSecretKey(secretKey)));
+
+        
assertTrue(viewContent.containsKey("SslContextFactory.KeyStoreFilePath"));
+        assertTrue(viewContent.containsKey("ConnectorConfiguration.Port"));
+
+        
assertFalse(viewContent.containsKey("SslContextFactory.KeyStorePassword"));
+        
assertFalse(viewContent.containsKey("SslContextFactory.TrustStorePassword"));
+        
assertFalse(viewContent.containsKey("ConnectorConfiguration.SecretKey"));
+
+        assertTrue(viewContent.values().stream().noneMatch(val -> val != null 
&& val.contains(secretKey)));
+    }
+
+    /** */
+    @Test
+    public void testCyclicReferences() throws Exception {
+        TestPluginConfiguration self = new TestPluginConfiguration();
+        self.setRef(self);
+
+        TestPluginConfiguration a = new TestPluginConfiguration();
+        TestPluginConfiguration b = new TestPluginConfiguration();
+        a.setRef(b);
+        b.setRef(a);
+
+        TestPluginConfiguration shared = new TestPluginConfiguration();
+        TestPluginConfiguration holder0 = new TestPluginConfiguration();
+        TestPluginConfiguration holder1 = new TestPluginConfiguration();
+        holder0.setRef(shared);
+        holder1.setRef(shared);
+
+        Map<String, String> viewContent = viewContent(getConfiguration()
+            .setPluginConfigurations(self, a, holder0, holder1, null));
+
+        // Self reference.
+        assertTrue(viewContent.containsKey("PluginConfigurations[0].Ref"));
+        
assertFalse(viewContent.containsKey("PluginConfigurations[0].Ref.Ref"));
+
+        // Cyclic reference.
+        assertTrue(viewContent.containsKey("PluginConfigurations[1].Ref.Ref"));
+        
assertFalse(viewContent.containsKey("PluginConfigurations[1].Ref.Ref.Ref"));
+
+        // Shared object without a cycle is exposed for each reference.
+        assertTrue(viewContent.containsKey("PluginConfigurations[2].Ref.Ref"));
+        assertTrue(viewContent.containsKey("PluginConfigurations[3].Ref.Ref"));
+
+        // Null array element is skipped.
+        assertTrue(viewContent.keySet().stream().noneMatch(name -> 
name.startsWith("PluginConfigurations[4]")));
+    }
+
+    /** Tests that an array without elements to iterate is exposed as a plain 
value. */
+    @Test
+    public void testArrayWithoutIterableElements() throws Exception {
+        TestPluginConfiguration nullsOnly = new TestPluginConfiguration();
+        nullsOnly.setRef(new TestPluginConfiguration[] {null, null});
+
+        TestPluginConfiguration cyclicOnly = new TestPluginConfiguration();
+        cyclicOnly.setRef(new TestPluginConfiguration[] {cyclicOnly});
+
+        TestPluginConfiguration empty = new TestPluginConfiguration();
+        empty.setRef(new TestPluginConfiguration[0]);
+
+        Map<String, String> viewContent = viewContent(getConfiguration()
+            .setPluginConfigurations(nullsOnly, cyclicOnly, empty));
+
+        assertEquals("[null, null]", 
viewContent.get("PluginConfigurations[0].Ref"));
+        assertNotNull(viewContent.get("PluginConfigurations[1].Ref"));
+        
assertFalse(viewContent.containsKey("PluginConfigurations[1].Ref[0].Ref"));
+        assertEquals("[]", viewContent.get("PluginConfigurations[2].Ref"));
+    }
+
+    /**
+     * @param icfg Configuration.
+     * @return Configuration view content: property names and values.
+     */
+    private static Map<String, String> viewContent(IgniteConfiguration icfg) {
+        Map<String, String> viewContent = new HashMap<>();
+
+        for (ConfigurationView row : new IgniteConfigurationIterable(icfg))
+            viewContent.put(row.name(), row.value());
+
+        return viewContent;
+    }
+
+    /** Plugin configuration with a reference to another object. */
+    public static class TestPluginConfiguration implements PluginConfiguration 
{
+        /** Reference. */
+        private Object ref;
+
+        /** @return Reference. */
+        public Object getRef() {
+            return ref;
+        }
+
+        /** @param ref Reference. */
+        public void setRef(Object ref) {
+            this.ref = ref;
+        }
+    }
+
+    /** Overrides sensitive property getter without {@link SensitiveProperty} 
annotation. */
+    public static class TestConnectorConfiguration extends 
ConnectorConfiguration {
+        /** {@inheritDoc} */
+        @Override public String getSecretKey() {
+            return super.getSecretKey();
+        }
+    }
 }

Reply via email to