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:09 UTC

[ignite] branch ignite-11155-dotnet-fix updated (c22138f -> 3ceb272)

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

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


    from c22138f  TODOs
     new 9c1e2ef  Implement warning suppression
     new 3ceb272  Implement warning suppression

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../Impl/Unmanaged/Jni/ConsoleWriter.cs            | 49 +++++++++++++++++++---
 1 file changed, 44 insertions(+), 5 deletions(-)


[ignite] 02/02: Implement warning suppression

Posted by pt...@apache.org.
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;
+        }
     }
 }


[ignite] 01/02: Implement warning suppression

Posted by pt...@apache.org.
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 9c1e2efc16c1ca16eadaa4e44120dd3eb5dbecfb
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Sat Feb 16 20:53:12 2019 +0300

    Implement warning suppression
---
 .../Impl/Unmanaged/Jni/ConsoleWriter.cs            | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

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 4faf18c..d5fe92f 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
@@ -26,6 +26,19 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
     /// </summary>
     internal sealed class ConsoleWriter : MarshalByRefObject
     {
+        /** Environment variable: whether to suppress stderr warnings from Java 11. */
+        public const string EnvIgniteNetSuppressJavaIllegalAccessWarnings =
+            "IGNITE_NET_SUPPRESS_JAVA_ILLEGAL_ACCESS_WARNINGS";
+
+        /** Flag: whether to suppress stderr warnings from Java 11. */
+        private readonly bool _suppressIllegalAccessWarnings;
+
+        public ConsoleWriter()
+        {
+            _suppressIllegalAccessWarnings =
+                Environment.GetEnvironmentVariable(EnvIgniteNetSuppressJavaIllegalAccessWarnings) == "true";
+        }
+
         /// <summary>
         /// Writes the specified message to console.
         /// </summary>
@@ -33,13 +46,8 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
             Justification = "Only instance methods can be called across AppDomain boundaries.")]
         public void Write(string message, bool isError)
         {
-            // TODO: Just a test
-            // This works! Just filter out unwanted warnings!
-            // We need to do it conditionally somehow, only for tests, to avoid perf implications.
-            if (!isError)
-            {
-                Console.Out.Write(message);
-            }
+            var target = isError ? Console.Error : Console.Out;
+            target.Write(message);
         }
 
         /** <inheritdoc /> */