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

nizhikov 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 ef8b439f6f8 IGNITE-24792 Move GridToStringBuilder to ignite-commons 
(#11978)
ef8b439f6f8 is described below

commit ef8b439f6f81e929c067c68f53acb0fa756f2650
Author: Nikolay <[email protected]>
AuthorDate: Tue Apr 8 11:03:09 2025 +0300

    IGNITE-24792 Move GridToStringBuilder to ignite-commons (#11978)
---
 .../ignite/IgniteCommonsSystemProperties.java      | 264 +++++++++++++++++++++
 .../java/org/apache/ignite/SystemProperty.java     |   0
 .../apache/ignite/internal/util/CommonUtils.java   |  10 +
 .../ignite/internal/util/GridCommonFunc.java       |  22 ++
 .../ignite/internal/util/GridStringBuilder.java    |   3 +-
 .../util/lang/gridfunc/StringConcatReducer.java    |   4 +-
 .../util/tostring/CircularStringBuilder.java       |   0
 .../util/tostring/GridToStringBuilder.java         |  24 +-
 .../util/tostring/GridToStringClassDescriptor.java |   0
 .../util/tostring/GridToStringExclude.java         |   0
 .../util/tostring/GridToStringFieldDescriptor.java |   1 -
 .../util/tostring/GridToStringInclude.java         |   4 +-
 .../internal/util/tostring/GridToStringOrder.java  |   0
 .../ReflectionToStringFieldDescriptor.java         |   0
 .../internal/util/tostring/SBLengthLimit.java      |   5 +-
 .../internal/util/tostring/SBLimitedLength.java    |   0
 .../internal/util/tostring/package-info.java       |   0
 .../ignite/internal/util/typedef/internal/S.java   |   0
 .../ignite/internal/util/typedef/internal/SB.java  |   0
 .../org/apache/ignite/IgniteSystemProperties.java  | 240 +------------------
 .../apache/ignite/internal/util/IgniteUtils.java   |  38 ++-
 .../apache/ignite/internal/util/lang/GridFunc.java |  20 --
 .../ignite/internal/util/IgniteUtilsSelfTest.java  |   5 +
 23 files changed, 339 insertions(+), 301 deletions(-)

diff --git 
a/modules/commons/src/main/java/org/apache/ignite/IgniteCommonsSystemProperties.java
 
b/modules/commons/src/main/java/org/apache/ignite/IgniteCommonsSystemProperties.java
new file mode 100644
index 00000000000..a1fca734d57
--- /dev/null
+++ 
b/modules/commons/src/main/java/org/apache/ignite/IgniteCommonsSystemProperties.java
@@ -0,0 +1,264 @@
+/*
+ * 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;
+
+import org.jetbrains.annotations.Nullable;
+
+import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_COLLECTION_LIMIT;
+import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_INCLUDE_SENSITIVE;
+import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_MAX_LENGTH;
+
+/**
+ * Contains constants for all common system properties and environmental 
variables in Ignite.
+ * These properties and variables can be used to affect the behavior of Ignite.
+ */
+public class IgniteCommonsSystemProperties {
+    /**
+     * Setting to {@code true} enables writing sensitive information in {@code 
toString()} output.
+     */
+    @SystemProperty(value = "Enables writing sensitive information in 
toString() output",
+        defaults = "" + DFLT_TO_STRING_INCLUDE_SENSITIVE)
+    public static final String IGNITE_TO_STRING_INCLUDE_SENSITIVE = 
"IGNITE_TO_STRING_INCLUDE_SENSITIVE";
+
+    /** Maximum length for {@code toString()} result. */
+    @SystemProperty(value = "Maximum length for toString() result", type = 
Integer.class,
+        defaults = "" + DFLT_TO_STRING_MAX_LENGTH)
+    public static final String IGNITE_TO_STRING_MAX_LENGTH = 
"IGNITE_TO_STRING_MAX_LENGTH";
+
+    /**
+     * Limit collection (map, array) elements number to output.
+     */
+    @SystemProperty(value = "Number of collection (map, array) elements to 
output",
+        type = Integer.class, defaults = "" + DFLT_TO_STRING_COLLECTION_LIMIT)
+    public static final String IGNITE_TO_STRING_COLLECTION_LIMIT = 
"IGNITE_TO_STRING_COLLECTION_LIMIT";
+
+    /**
+     * @param enumCls Enum type.
+     * @param name Name of the system property or environment variable.
+     * @param <E> Type of the enum.
+     * @return Enum value or {@code null} if the property is not set.
+     */
+    public static <E extends Enum<E>> E getEnum(Class<E> enumCls, String name) 
{
+        return getEnum(enumCls, name, null);
+    }
+
+    /**
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value if property is not set.
+     * @param <E> Type of the enum.
+     * @return Enum value or the given default.
+     */
+    public static <E extends Enum<E>> E getEnum(String name, E dflt) {
+        return getEnum(dflt.getDeclaringClass(), name, dflt);
+    }
+
+    /**
+     * @param enumCls Enum type.
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value.
+     * @return Enum value or the given default.
+     */
+    private static <E extends Enum<E>> E getEnum(Class<E> enumCls, String 
name, E dflt) {
+        assert enumCls != null;
+
+        String val = getString(name);
+
+        if (val == null)
+            return dflt;
+
+        try {
+            return Enum.valueOf(enumCls, val);
+        }
+        catch (IllegalArgumentException ignore) {
+            return dflt;
+        }
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     *
+     * @param name Name of the system property or environment variable.
+     * @return Value of the system property or environment variable.
+     *         Returns {@code null} if neither can be found for given name.
+     */
+    @Nullable public static String getString(String name) {
+        assert name != null;
+
+        String v = System.getProperty(name);
+
+        if (v == null)
+            v = System.getenv(name);
+
+        return v;
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     *
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value.
+     * @return Value of the system property or environment variable.
+     *         Returns {@code null} if neither can be found for given name.
+     */
+    @Nullable public static String getString(String name, String dflt) {
+        String val = getString(name);
+
+        return val == null ? dflt : val;
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     * The result is transformed to {@code boolean} using {@code 
Boolean.valueOf()} method.
+     *
+     * @param name Name of the system property or environment variable.
+     * @return Boolean value of the system property or environment variable.
+     *         Returns {@code False} in case neither system property
+     *         nor environment variable with given name is found.
+     */
+    public static boolean getBoolean(String name) {
+        return getBoolean(name, false);
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     * The result is transformed to {@code boolean} using {@code 
Boolean.valueOf()} method.
+     *
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value.
+     * @return Boolean value of the system property or environment variable.
+     *         Returns default value in case neither system property
+     *         nor environment variable with given name is found.
+     */
+    public static boolean getBoolean(String name, boolean dflt) {
+        String val = getString(name);
+
+        return val == null ? dflt : Boolean.parseBoolean(val);
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     * The result is transformed to {@code int} using {@code 
Integer.parseInt()} method.
+     *
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value.
+     * @return Integer value of the system property or environment variable.
+     *         Returns default value in case neither system property
+     *         nor environment variable with given name is found.
+     */
+    public static int getInteger(String name, int dflt) {
+        String s = getString(name);
+
+        if (s == null)
+            return dflt;
+
+        int res;
+
+        try {
+            res = Integer.parseInt(s);
+        }
+        catch (NumberFormatException ignore) {
+            res = dflt;
+        }
+
+        return res;
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     * The result is transformed to {@code float} using {@code 
Float.parseFloat()} method.
+     *
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value.
+     * @return Float value of the system property or environment variable.
+     *         Returns default value in case neither system property
+     *         nor environment variable with given name is found.
+     */
+    public static float getFloat(String name, float dflt) {
+        String s = getString(name);
+
+        if (s == null)
+            return dflt;
+
+        float res;
+
+        try {
+            res = Float.parseFloat(s);
+        }
+        catch (NumberFormatException ignore) {
+            res = dflt;
+        }
+
+        return res;
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     * The result is transformed to {@code long} using {@code 
Long.parseLong()} method.
+     *
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value.
+     * @return Integer value of the system property or environment variable.
+     *         Returns default value in case neither system property
+     *         nor environment variable with given name is found.
+     */
+    public static long getLong(String name, long dflt) {
+        String s = getString(name);
+
+        if (s == null)
+            return dflt;
+
+        long res;
+
+        try {
+            res = Long.parseLong(s);
+        }
+        catch (NumberFormatException ignore) {
+            res = dflt;
+        }
+
+        return res;
+    }
+
+    /**
+     * Gets either system property or environment variable with given name.
+     * The result is transformed to {@code double} using {@code 
Double.parseDouble()} method.
+     *
+     * @param name Name of the system property or environment variable.
+     * @param dflt Default value.
+     * @return Integer value of the system property or environment variable.
+     *         Returns default value in case neither system property
+     *         nor environment variable with given name is found.
+     */
+    public static double getDouble(String name, double dflt) {
+        String s = getString(name);
+
+        if (s == null)
+            return dflt;
+
+        double res;
+
+        try {
+            res = Double.parseDouble(s);
+        }
+        catch (NumberFormatException ignore) {
+            res = dflt;
+        }
+
+        return res;
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/SystemProperty.java 
b/modules/commons/src/main/java/org/apache/ignite/SystemProperty.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/SystemProperty.java
rename to modules/commons/src/main/java/org/apache/ignite/SystemProperty.java
diff --git 
a/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
index 489b9968962..4f26fbe15fd 100644
--- 
a/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
@@ -36,6 +36,9 @@ public abstract class CommonUtils {
     /** Public {@code java.lang.Object} no-argument constructor. */
     private static final Constructor OBJECT_CTOR;
 
+    /** System line separator. */
+    static final String NL = System.getProperty("line.separator");
+
     static {
         try {
             OBJECT_CTOR = Object.class.getConstructor();
@@ -157,4 +160,11 @@ public abstract class CommonUtils {
 
         return Integer.MAX_VALUE; // any large value
     }
+
+    /**
+     * @return {@code line.separator} system property.
+     */
+    public static String nl() {
+        return NL;
+    }
 }
diff --git 
a/modules/commons/src/main/java/org/apache/ignite/internal/util/GridCommonFunc.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridCommonFunc.java
index 53acc7b7480..ae5530ee3de 100644
--- 
a/modules/commons/src/main/java/org/apache/ignite/internal/util/GridCommonFunc.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridCommonFunc.java
@@ -19,6 +19,9 @@ package org.apache.ignite.internal.util;
 
 import java.util.Collection;
 import java.util.Map;
+import org.apache.ignite.internal.util.lang.gridfunc.StringConcatReducer;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.lang.IgniteReducer;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -42,6 +45,25 @@ import org.jetbrains.annotations.Nullable;
  * <b>Remove when GridFunc migrated</b>
  */
 public class GridCommonFunc {
+    /**
+     * Concatenates strings using provided delimiter.
+     *
+     * @param c Input collection.
+     * @param delim Delimiter (optional).
+     * @return Concatenated string.
+     */
+    public static String concat(Iterable<?> c, @Nullable String delim) {
+        A.notNull(c, "c");
+
+        IgniteReducer<? super String, String> f = new 
StringConcatReducer(delim);
+
+        for (Object x : c)
+            if (!f.collect(x == null ? null : x.toString()))
+                break;
+
+        return f.reduce();
+    }
+
     /**
      * Tests if given string is {@code null} or empty.
      *
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
similarity index 99%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
index f9f6ae26a33..75f0913b0aa 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
  * Optimized string builder with better API.
@@ -280,7 +279,7 @@ public class GridStringBuilder implements Serializable {
      * @return This buffer for chaining method calls.
      */
     public GridStringBuilder nl() {
-        impl.append(U.nl());
+        impl.append(CommonUtils.nl());
 
         return this;
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/StringConcatReducer.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/StringConcatReducer.java
similarity index 95%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/StringConcatReducer.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/StringConcatReducer.java
index 4a2b2a39226..cf03256b78f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/StringConcatReducer.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/StringConcatReducer.java
@@ -17,7 +17,7 @@
 
 package org.apache.ignite.internal.util.lang.gridfunc;
 
-import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.CF;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.lang.IgniteReducer;
@@ -54,7 +54,7 @@ public class StringConcatReducer implements 
IgniteReducer<String, String> {
     /** {@inheritDoc} */
     @Override public boolean collect(String s) {
         synchronized (lock) {
-            if (!first && !GridFunc.isEmpty(delim))
+            if (!first && !CF.isEmpty(delim))
                 sb.a(delim);
 
             sb.a(s);
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/CircularStringBuilder.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/CircularStringBuilder.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/CircularStringBuilder.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/CircularStringBuilder.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
similarity index 98%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
index 9b13ede9557..b595fef29a8 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
@@ -41,17 +41,17 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.function.Function;
 import java.util.function.Supplier;
+import org.apache.ignite.IgniteCommonsSystemProperties;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.CF;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import static java.util.Objects.nonNull;
-import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_COLLECTION_LIMIT;
-import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_INCLUDE_SENSITIVE;
-import static org.apache.ignite.IgniteSystemProperties.getBoolean;
+import static 
org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_TO_STRING_COLLECTION_LIMIT;
+import static 
org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_TO_STRING_INCLUDE_SENSITIVE;
+import static org.apache.ignite.IgniteCommonsSystemProperties.getBoolean;
 
 /**
  * Provides auto-generation framework for {@code toString()} output.
@@ -101,10 +101,10 @@ public class GridToStringBuilder {
     /** */
     public static volatile Function<Field, GridToStringFieldDescriptor> 
fldDescFactory = ReflectionToStringFieldDescriptor::new;
 
-    /** @see IgniteSystemProperties#IGNITE_TO_STRING_MAX_LENGTH */
+    /** @see IgniteCommonsSystemProperties#IGNITE_TO_STRING_MAX_LENGTH */
     public static final int DFLT_TO_STRING_MAX_LENGTH = 10_000;
 
-    /** @see IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE */
+    /** @see IgniteCommonsSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE 
*/
     public static final boolean DFLT_TO_STRING_INCLUDE_SENSITIVE = true;
 
     /** Supplier for {@link #includeSensitive} with default behavior. */
@@ -120,12 +120,12 @@ public class GridToStringBuilder {
             }
         });
 
-    /** @see IgniteSystemProperties#IGNITE_TO_STRING_COLLECTION_LIMIT */
+    /** @see IgniteCommonsSystemProperties#IGNITE_TO_STRING_COLLECTION_LIMIT */
     public static final int DFLT_TO_STRING_COLLECTION_LIMIT = 100;
 
     /** */
     public static final int COLLECTION_LIMIT =
-        IgniteSystemProperties.getInteger(IGNITE_TO_STRING_COLLECTION_LIMIT, 
DFLT_TO_STRING_COLLECTION_LIMIT);
+        
IgniteCommonsSystemProperties.getInteger(IGNITE_TO_STRING_COLLECTION_LIMIT, 
DFLT_TO_STRING_COLLECTION_LIMIT);
 
     /** Every thread has its own string builder. */
     private static ThreadLocal<SBLimitedLength> threadLocSB = new 
ThreadLocal<SBLimitedLength>() {
@@ -161,7 +161,7 @@ public class GridToStringBuilder {
     /**
      * Setting the logic of the {@link #includeSensitive} method. <br/>
      * By default, it take the value of
-     * {@link IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE
+     * {@link IgniteCommonsSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE
      * IGNITE_TO_STRING_INCLUDE_SENSITIVE} system property. <br/>
      * <b>Important!</b> Changing the logic is possible only until the first
      * call of  {@link #includeSensitive} method. <br/>
@@ -1895,7 +1895,7 @@ public class GridToStringBuilder {
         if (c.isEmpty())
             return "[]";
 
-        return '[' + F.concat(new TreeSet<>(c), ",") + ']';
+        return '[' + CF.concat(new TreeSet<>(c), ",") + ']';
     }
 
     /**
@@ -1970,7 +1970,7 @@ public class GridToStringBuilder {
         int maxLen,
         int maxCnt
     ) {
-        if (F.isEmpty(list))
+        if (CF.isEmpty(list))
             return "";
 
         SB buf = new SB();
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringClassDescriptor.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringClassDescriptor.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringClassDescriptor.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringClassDescriptor.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringExclude.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringExclude.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringExclude.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringExclude.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringFieldDescriptor.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringFieldDescriptor.java
similarity index 99%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringFieldDescriptor.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringFieldDescriptor.java
index 37a6aee131e..ba42f14d39f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringFieldDescriptor.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringFieldDescriptor.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.util.tostring;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import org.apache.ignite.internal.util.GridUnsafe;
 import org.intellij.lang.annotations.MagicConstant;
 
 /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringInclude.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringInclude.java
similarity index 91%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringInclude.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringInclude.java
index 8a6d115272a..f7af38d59ff 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringInclude.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringInclude.java
@@ -22,7 +22,7 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
-import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.IgniteCommonsSystemProperties;
 
 /**
  * Attach this annotation to a field or a class to indicate that this field or 
fields of this
@@ -36,7 +36,7 @@ public @interface GridToStringInclude {
     /**
      * A flag indicating a sensitive information stored in the field or fields 
of the class.<br/>
      * Such information will be included in {@code toString()} output ONLY 
when the system property
-     * {@link IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE 
IGNITE_TO_STRING_INCLUDE_SENSITIVE}
+     * {@link IgniteCommonsSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE 
IGNITE_TO_STRING_INCLUDE_SENSITIVE}
      * is set to {@code true}.
      *
      * @return Attribute value.
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringOrder.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringOrder.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringOrder.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringOrder.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/ReflectionToStringFieldDescriptor.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/ReflectionToStringFieldDescriptor.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/ReflectionToStringFieldDescriptor.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/ReflectionToStringFieldDescriptor.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLengthLimit.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/SBLengthLimit.java
similarity index 90%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLengthLimit.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/SBLengthLimit.java
index 883b910c4a8..58a070eef3a 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLengthLimit.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/SBLengthLimit.java
@@ -17,9 +17,8 @@
 
 package org.apache.ignite.internal.util.tostring;
 
-import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.IgniteCommonsSystemProperties;
 
-import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_MAX_LENGTH;
 import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_MAX_LENGTH;
 
 /**
@@ -28,7 +27,7 @@ import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_
 class SBLengthLimit {
     /** */
     private static final int MAX_TO_STR_LEN =
-        IgniteSystemProperties.getInteger(IGNITE_TO_STRING_MAX_LENGTH, 
DFLT_TO_STRING_MAX_LENGTH);
+        
IgniteCommonsSystemProperties.getInteger(IgniteCommonsSystemProperties.IGNITE_TO_STRING_MAX_LENGTH,
 DFLT_TO_STRING_MAX_LENGTH);
 
     /** Length of tail part of message. */
     private static final int TAIL_LEN = MAX_TO_STR_LEN / 10 * 2;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/package-info.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/package-info.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/tostring/package-info.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/package-info.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/typedef/internal/S.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/internal/S.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/typedef/internal/S.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/internal/S.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/typedef/internal/SB.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/internal/SB.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/typedef/internal/SB.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/internal/SB.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java 
b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 5dfb01f5ded..aa0cb5087ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -50,7 +50,6 @@ import org.apache.ignite.mxbean.MetricsMxBean;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry;
 import org.apache.ignite.stream.StreamTransformer;
-import org.jetbrains.annotations.Nullable;
 
 import static 
org.apache.ignite.cache.CacheManager.DFLT_JCACHE_DEFAULT_ISOLATED;
 import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_USE_ASYNC_FILE_IO_FACTORY;
@@ -146,9 +145,6 @@ import static 
org.apache.ignite.internal.util.IgniteUtils.DFLT_MBEAN_APPEND_CLAS
 import static 
org.apache.ignite.internal.util.StripedExecutor.DFLT_DATA_STREAMING_EXECUTOR_SERVICE_TASKS_STEALING_THRESHOLD;
 import static 
org.apache.ignite.internal.util.nio.GridNioRecoveryDescriptor.DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT;
 import static 
org.apache.ignite.internal.util.nio.GridNioServer.DFLT_IO_BALANCE_PERIOD;
-import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_COLLECTION_LIMIT;
-import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_INCLUDE_SENSITIVE;
-import static 
org.apache.ignite.internal.util.tostring.GridToStringBuilder.DFLT_TO_STRING_MAX_LENGTH;
 import static 
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_DISCOVERY_CLIENT_RECONNECT_HISTORY_SIZE;
 import static 
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_DISCOVERY_METRICS_QNT_WARN;
 import static 
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_DISCO_FAILED_CLIENT_RECONNECT_DELAY;
@@ -160,7 +156,7 @@ import static 
org.apache.ignite.startup.cmdline.CommandLineStartup.DFLT_PROG_NAM
  * Contains constants for all system properties and environmental variables in 
Ignite.
  * These properties and variables can be used to affect the behavior of Ignite.
  */
-public final class IgniteSystemProperties {
+public final class IgniteSystemProperties extends 
IgniteCommonsSystemProperties {
     /**
      * If this system property is present the Ignite will include grid name 
into verbose log.
      *
@@ -334,25 +330,6 @@ public final class IgniteSystemProperties {
         "logs without performance penalty")
     public static final String IGNITE_TROUBLESHOOTING_LOGGER = 
"IGNITE_TROUBLESHOOTING_LOGGER";
 
-    /**
-     * Setting to {@code true} enables writing sensitive information in {@code 
toString()} output.
-     */
-    @SystemProperty(value = "Enables writing sensitive information in 
toString() output",
-        defaults = "" + DFLT_TO_STRING_INCLUDE_SENSITIVE)
-    public static final String IGNITE_TO_STRING_INCLUDE_SENSITIVE = 
"IGNITE_TO_STRING_INCLUDE_SENSITIVE";
-
-    /** Maximum length for {@code toString()} result. */
-    @SystemProperty(value = "Maximum length for toString() result", type = 
Integer.class,
-        defaults = "" + DFLT_TO_STRING_MAX_LENGTH)
-    public static final String IGNITE_TO_STRING_MAX_LENGTH = 
"IGNITE_TO_STRING_MAX_LENGTH";
-
-    /**
-     * Limit collection (map, array) elements number to output.
-     */
-    @SystemProperty(value = "Number of collection (map, array) elements to 
output",
-        type = Integer.class, defaults = "" + DFLT_TO_STRING_COLLECTION_LIMIT)
-    public static final String IGNITE_TO_STRING_COLLECTION_LIMIT = 
"IGNITE_TO_STRING_COLLECTION_LIMIT";
-
     /**
      * If this property is set to {@code true} (default) and Ignite is launched
      * in verbose mode (see {@link #IGNITE_QUIET}) and no console appenders 
can be found
@@ -2120,221 +2097,6 @@ public final class IgniteSystemProperties {
         // No-op.
     }
 
-    /**
-     * @param enumCls Enum type.
-     * @param name Name of the system property or environment variable.
-     * @param <E> Type of the enum.
-     * @return Enum value or {@code null} if the property is not set.
-     */
-    public static <E extends Enum<E>> E getEnum(Class<E> enumCls, String name) 
{
-        return getEnum(enumCls, name, null);
-    }
-
-    /**
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value if property is not set.
-     * @param <E> Type of the enum.
-     * @return Enum value or the given default.
-     */
-    public static <E extends Enum<E>> E getEnum(String name, E dflt) {
-        return getEnum(dflt.getDeclaringClass(), name, dflt);
-    }
-
-    /**
-     * @param enumCls Enum type.
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value.
-     * @return Enum value or the given default.
-     */
-    private static <E extends Enum<E>> E getEnum(Class<E> enumCls, String 
name, E dflt) {
-        assert enumCls != null;
-
-        String val = getString(name);
-
-        if (val == null)
-            return dflt;
-
-        try {
-            return Enum.valueOf(enumCls, val);
-        }
-        catch (IllegalArgumentException ignore) {
-            return dflt;
-        }
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     *
-     * @param name Name of the system property or environment variable.
-     * @return Value of the system property or environment variable.
-     *         Returns {@code null} if neither can be found for given name.
-     */
-    @Nullable public static String getString(String name) {
-        assert name != null;
-
-        String v = System.getProperty(name);
-
-        if (v == null)
-            v = System.getenv(name);
-
-        return v;
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     *
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value.
-     * @return Value of the system property or environment variable.
-     *         Returns {@code null} if neither can be found for given name.
-     */
-    @Nullable public static String getString(String name, String dflt) {
-        String val = getString(name);
-
-        return val == null ? dflt : val;
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     * The result is transformed to {@code boolean} using {@code 
Boolean.valueOf()} method.
-     *
-     * @param name Name of the system property or environment variable.
-     * @return Boolean value of the system property or environment variable.
-     *         Returns {@code False} in case neither system property
-     *         nor environment variable with given name is found.
-     */
-    public static boolean getBoolean(String name) {
-        return getBoolean(name, false);
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     * The result is transformed to {@code boolean} using {@code 
Boolean.valueOf()} method.
-     *
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value.
-     * @return Boolean value of the system property or environment variable.
-     *         Returns default value in case neither system property
-     *         nor environment variable with given name is found.
-     */
-    public static boolean getBoolean(String name, boolean dflt) {
-        String val = getString(name);
-
-        return val == null ? dflt : Boolean.parseBoolean(val);
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     * The result is transformed to {@code int} using {@code 
Integer.parseInt()} method.
-     *
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value.
-     * @return Integer value of the system property or environment variable.
-     *         Returns default value in case neither system property
-     *         nor environment variable with given name is found.
-     */
-    public static int getInteger(String name, int dflt) {
-        String s = getString(name);
-
-        if (s == null)
-            return dflt;
-
-        int res;
-
-        try {
-            res = Integer.parseInt(s);
-        }
-        catch (NumberFormatException ignore) {
-            res = dflt;
-        }
-
-        return res;
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     * The result is transformed to {@code float} using {@code 
Float.parseFloat()} method.
-     *
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value.
-     * @return Float value of the system property or environment variable.
-     *         Returns default value in case neither system property
-     *         nor environment variable with given name is found.
-     */
-    public static float getFloat(String name, float dflt) {
-        String s = getString(name);
-
-        if (s == null)
-            return dflt;
-
-        float res;
-
-        try {
-            res = Float.parseFloat(s);
-        }
-        catch (NumberFormatException ignore) {
-            res = dflt;
-        }
-
-        return res;
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     * The result is transformed to {@code long} using {@code 
Long.parseLong()} method.
-     *
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value.
-     * @return Integer value of the system property or environment variable.
-     *         Returns default value in case neither system property
-     *         nor environment variable with given name is found.
-     */
-    public static long getLong(String name, long dflt) {
-        String s = getString(name);
-
-        if (s == null)
-            return dflt;
-
-        long res;
-
-        try {
-            res = Long.parseLong(s);
-        }
-        catch (NumberFormatException ignore) {
-            res = dflt;
-        }
-
-        return res;
-    }
-
-    /**
-     * Gets either system property or environment variable with given name.
-     * The result is transformed to {@code double} using {@code 
Double.parseDouble()} method.
-     *
-     * @param name Name of the system property or environment variable.
-     * @param dflt Default value.
-     * @return Integer value of the system property or environment variable.
-     *         Returns default value in case neither system property
-     *         nor environment variable with given name is found.
-     */
-    public static double getDouble(String name, double dflt) {
-        String s = getString(name);
-
-        if (s == null)
-            return dflt;
-
-        double res;
-
-        try {
-            res = Double.parseDouble(s);
-        }
-        catch (NumberFormatException ignore) {
-            res = dflt;
-        }
-
-        return res;
-    }
-
     /**
      * Gets snapshot of system properties.
      * Snapshot could be used for thread safe iteration over system properties.
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 17d1ee93dd2..172651fd332 100755
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -375,9 +375,6 @@ public abstract class IgniteUtils extends CommonUtils {
     /** */
     public static final UUID[] EMPTY_UUIDS = new UUID[0];
 
-    /** System line separator. */
-    private static final String NL = System.getProperty("line.separator");
-
     /** Default user version. */
     public static final String DFLT_USER_VERSION = "0";
 
@@ -8495,13 +8492,6 @@ public abstract class IgniteUtils extends CommonUtils {
         return false;
     }
 
-    /**
-     * @return {@code line.separator} system property.
-     */
-    public static String nl() {
-        return NL;
-    }
-
     /**
      * Initializes logger into/from log reference passed in.
      *
@@ -8913,20 +8903,28 @@ public abstract class IgniteUtils extends CommonUtils {
         assert fieldName != null;
 
         try {
-            for (Field field : cls.getDeclaredFields())
-                if (field.getName().equals(fieldName)) {
-                    boolean accessible = field.isAccessible();
+            do {
+                for (Field field : cls.getDeclaredFields())
+                    if (field.getName().equals(fieldName)) {
+                        boolean accessible = field.isAccessible();
 
-                    if (!accessible)
-                        field.setAccessible(true);
+                        if (!accessible)
+                            field.setAccessible(true);
 
-                    T val = (T)field.get(null);
+                        T val = (T)field.get(null);
 
-                    if (!accessible)
-                        field.setAccessible(false);
+                        if (!accessible)
+                            field.setAccessible(false);
 
-                    return val;
-                }
+                        return val;
+                    }
+
+                if (cls == Object.class)
+                    break;
+
+                cls = cls.getSuperclass();
+            }
+            while (true);
         }
         catch (Exception e) {
             throw new IgniteCheckedException("Failed to get field value 
[fieldName=" + fieldName + ", cls=" + cls + ']', e);
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java 
b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 546f3c67260..11b678f671d 100755
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -75,7 +75,6 @@ import 
org.apache.ignite.internal.util.lang.gridfunc.PredicateSetView;
 import org.apache.ignite.internal.util.lang.gridfunc.ReadOnlyCollectionView;
 import org.apache.ignite.internal.util.lang.gridfunc.ReadOnlyCollectionView2X;
 import org.apache.ignite.internal.util.lang.gridfunc.SetFactoryCallable;
-import org.apache.ignite.internal.util.lang.gridfunc.StringConcatReducer;
 import org.apache.ignite.internal.util.lang.gridfunc.TransformCollectionView;
 import 
org.apache.ignite.internal.util.lang.gridfunc.TransformFilteringIterator;
 import org.apache.ignite.internal.util.lang.gridfunc.TransformMapView;
@@ -198,25 +197,6 @@ public class GridFunc extends GridCommonFunc {
         return new AlwaysTrueReducer<>(elem);
     }
 
-    /**
-     * Concatenates strings using provided delimiter.
-     *
-     * @param c Input collection.
-     * @param delim Delimiter (optional).
-     * @return Concatenated string.
-     */
-    public static String concat(Iterable<?> c, @Nullable String delim) {
-        A.notNull(c, "c");
-
-        IgniteReducer<? super String, String> f = new 
StringConcatReducer(delim);
-
-        for (Object x : c)
-            if (!f.collect(x == null ? null : x.toString()))
-                break;
-
-        return f.reduce();
-    }
-
     /**
      * Convenient utility method that returns collection of node IDs for a 
given
      * collection of grid nodes.
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
index ae594d9fa35..46b7efde4e3 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
@@ -1683,4 +1683,9 @@ public class IgniteUtilsSelfTest extends 
GridCommonAbstractTest {
         assertEquals(3, U.hashToIndex(-15, 4));
     }
 
+    /** Test {@link U#staticField(Class, String)} throws on unknown field. */
+    @Test(expected = IgniteCheckedException.class)
+    public void testReadUnknownStaticFieldFailed() throws Exception {
+        U.staticField(String.class, "unknown_field");
+    }
 }


Reply via email to