You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/02/05 11:33:56 UTC

[GitHub] [ignite] alex-plekhanov commented on a change in pull request #8746: IGNITE-14020 .NET: Services exceptions interoperability between java …

alex-plekhanov commented on a change in pull request #8746:
URL: https://github.com/apache/ignite/pull/8746#discussion_r570905400



##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginProcessor.cs
##########
@@ -145,18 +149,40 @@ public ExceptionFactory GetExceptionMapping(string className)
 
             ExceptionFactory res;
 
-            return _exceptionMappings.TryGetValue(className, out res) ? res : null;
+            if (_exactExceptionMappings.TryGetValue(className, out res))
+            {
+                return res;
+            }
+
+            foreach (var mapping in _patternExceptionMappings)
+            {
+                if (className.StartsWith(mapping.Key))
+                {
+                    return mapping.Value;
+                }
+            }
+
+            return null;
         }
 
         /// <summary>
         /// Registers the exception mapping.
         /// </summary>
+        /// <param name="className">Full class name of java exception or class name pattern (if ends with '*').</param>
+        /// <param name="factory">Exception factory for matched java class name.</param>
         public void RegisterExceptionMapping(string className, ExceptionFactory factory)
         {
             Debug.Assert(className != null);
             Debug.Assert(factory != null);
 
-            _exceptionMappings.GetOrAdd(className, _ => factory);
+            if (className.EndsWith("*"))

Review comment:
       Thanks, fixed.

##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginProcessor.cs
##########
@@ -145,18 +149,40 @@ public ExceptionFactory GetExceptionMapping(string className)
 
             ExceptionFactory res;
 
-            return _exceptionMappings.TryGetValue(className, out res) ? res : null;
+            if (_exactExceptionMappings.TryGetValue(className, out res))
+            {
+                return res;
+            }
+
+            foreach (var mapping in _patternExceptionMappings)
+            {
+                if (className.StartsWith(mapping.Key))
+                {
+                    return mapping.Value;
+                }
+            }
+
+            return null;
         }
 
         /// <summary>
         /// Registers the exception mapping.
         /// </summary>
+        /// <param name="className">Full class name of java exception or class name pattern (if ends with '*').</param>
+        /// <param name="factory">Exception factory for matched java class name.</param>
         public void RegisterExceptionMapping(string className, ExceptionFactory factory)
         {
             Debug.Assert(className != null);
             Debug.Assert(factory != null);
 
-            _exceptionMappings.GetOrAdd(className, _ => factory);
+            if (className.EndsWith("*"))
+            {
+                _patternExceptionMappings.GetOrAdd(className.TrimEnd('*'), _ => factory);

Review comment:
       Thanks, fixed.

##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginProcessor.cs
##########
@@ -145,18 +149,40 @@ public ExceptionFactory GetExceptionMapping(string className)
 
             ExceptionFactory res;
 
-            return _exceptionMappings.TryGetValue(className, out res) ? res : null;
+            if (_exactExceptionMappings.TryGetValue(className, out res))
+            {
+                return res;
+            }
+
+            foreach (var mapping in _patternExceptionMappings)
+            {
+                if (className.StartsWith(mapping.Key))

Review comment:
       Thanks, fixed.




----------------------------------------------------------------
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:
users@infra.apache.org