You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/02/20 07:47:54 UTC

[ignite] branch master updated: IGNITE-11233 Fix for .NET build: Ignite Build for Java 11 does not reuse ignite-tools from Build Apache Ignite (Fixes #6127)

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

dpavlov 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 1dbf57b  IGNITE-11233 Fix for .NET build: Ignite Build for Java 11 does not reuse ignite-tools from Build Apache Ignite (Fixes #6127)
1dbf57b is described below

commit 1dbf57bc58c480a4c5500ed0ecb04a18d07fbcd3
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Wed Feb 20 10:46:45 2019 +0300

    IGNITE-11233 Fix for .NET build: Ignite Build for Java 11 does not reuse ignite-tools from Build Apache Ignite (Fixes #6127)
---
 .../Common/TestUtils.DotNetCore.cs                 |  1 +
 .../Impl/Unmanaged/Jni/ConsoleWriter.cs            | 44 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs
index 08cae96..f524878 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs
@@ -34,6 +34,7 @@ namespace Apache.Ignite.Core.Tests
             TestLogger.Instance.Info("GetTestConfiguration: " + GetTestName());
 
             Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true");
+            Environment.SetEnvironmentVariable("IGNITE_NET_SUPPRESS_JAVA_ILLEGAL_ACCESS_WARNINGS", "true");
 
             return new IgniteConfiguration
             {
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 b1baf79..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
@@ -26,6 +26,29 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
     /// </summary>
     internal sealed class ConsoleWriter : MarshalByRefObject
     {
+        /** Environment variable: whether to suppress stderr warnings from Java 11. */
+        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;
+
+        public ConsoleWriter()
+        {
+            _suppressIllegalAccessWarnings =
+                Environment.GetEnvironmentVariable(EnvIgniteNetSuppressJavaIllegalAccessWarnings) == "true";
+        }
+
         /// <summary>
         /// Writes the specified message to console.
         /// </summary>
@@ -33,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);
         }
@@ -43,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;
+        }
     }
 }