alex-plekhanov commented on a change in pull request #6845: IGNITE-12145: 
Monitoring list engine.
URL: https://github.com/apache/ignite/pull/6845#discussion_r323689188
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
 ##########
 @@ -7040,6 +7042,51 @@ public static String toShortString(Collection<? extends 
ClusterNode> ns) {
         return sb.a(']').toString();
     }
 
+    /**
+     * Get string representation of an object properly catching all exceptions.
+     *
+     * @param obj Object.
+     * @return Result or {@code null}.
+     */
+    @Nullable public static String toStringSafe(@Nullable Object obj) {
+        if (obj == null)
+            return null;
+        else {
+            try {
+                return obj.toString();
+            }
+            catch (Exception e) {
+                try {
+                    return "Failed to convert object to string: " + 
e.getMessage();
+                }
+                catch (Exception e0) {
+                    return "Failed to convert object to string (error message 
is not available)";
+                }
+            }
+        }
+    }
+
+    /**
+     * @param objs Collection of objects.
+     * @return String representation.
+     */
+    @Nullable public static String toStringSafe(@Nullable Collection<String> 
objs) {
 
 Review comment:
   See no usages of this method. Did I miss something?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to