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

[ignite] 01/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 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 /> */