You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2019/02/16 17:59:11 UTC

[ignite] 02/02: Implement warning suppression

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

ptupitsyn pushed a commit to branch ignite-11155-dotnet-fix
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 3ceb272a7b109906174b69a577f5ded92732d109
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Sat Feb 16 20:59:01 2019 +0300

    Implement warning suppression
---
 .../Impl/Unmanaged/Jni/ConsoleWriter.cs            | 33 +++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/ConsoleWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/ConsoleWriter.cs
index d5fe92f..512afed 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/ConsoleWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/ConsoleWriter.cs
@@ -27,9 +27,19 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
     internal sealed class ConsoleWriter : MarshalByRefObject
     {
         /** Environment variable: whether to suppress stderr warnings from Java 11. */
-        public const string EnvIgniteNetSuppressJavaIllegalAccessWarnings =
+        private const string EnvIgniteNetSuppressJavaIllegalAccessWarnings =
             "IGNITE_NET_SUPPRESS_JAVA_ILLEGAL_ACCESS_WARNINGS";
 
+        /** Warnings to suppress. */
+        private static readonly string[] JavaIllegalAccessWarnings =
+        {
+            "WARNING: An illegal reflective access operation has occurred",
+            "WARNING: Illegal reflective access by org.apache.ignite.internal.util.GridUnsafe$2",
+            "WARNING: Please consider reporting this to the maintainers of",
+            "WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations",
+            "WARNING: All illegal access operations will be denied in a future release"
+        };
+
         /** Flag: whether to suppress stderr warnings from Java 11. */
         private readonly bool _suppressIllegalAccessWarnings;
 
@@ -46,6 +56,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
             Justification = "Only instance methods can be called across AppDomain boundaries.")]
         public void Write(string message, bool isError)
         {
+            if (_suppressIllegalAccessWarnings && isError && IsKnownWarning(message))
+            {
+                return;
+            }
+
             var target = isError ? Console.Error : Console.Out;
             target.Write(message);
         }
@@ -56,5 +71,21 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
             // Ensure that cross-AppDomain reference lives forever.
             return null;
         }
+
+        /// <summary>
+        /// Returns a value indicating whether provided message is a known warning.
+        /// </summary>
+        private static bool IsKnownWarning(string message)
+        {
+            foreach (var warning in JavaIllegalAccessWarnings)
+            {
+                if (message.StartsWith(warning, StringComparison.Ordinal))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
     }
 }