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

irakov 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 3110d72  IGNITE-12163 .NET: CacheEntryEventType.Removed is not being 
risen - Fixes #6862.
3110d72 is described below

commit 3110d7230182ef61222b74b1a7123c45ef646775
Author: Aleksandr Shapkin <ashap...@gridgain.com>
AuthorDate: Wed Sep 11 20:31:54 2019 +0300

    IGNITE-12163 .NET: CacheEntryEventType.Removed is not being risen - Fixes 
#6862.
    
    Signed-off-by: Ivan Rakov <ira...@apache.org>
---
 .../processors/platform/utils/PlatformUtils.java     | 18 ++++++++++++++++++
 .../include/ignite/cache/event/cache_entry_event.h   |  3 +++
 .../Query/Continuous/ContinuousQueryAbstractTest.cs  | 18 ++++++++++--------
 .../Cache/Query/Continuous/ContinuousQueryUtils.cs   | 20 +++++++++++++-------
 4 files changed, 44 insertions(+), 15 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 4881e5c..5b12c01 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -63,6 +63,7 @@ import org.jetbrains.annotations.Nullable;
 import javax.cache.CacheException;
 import javax.cache.event.CacheEntryEvent;
 import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.EventType;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.security.Timestamp;
@@ -612,6 +613,23 @@ public class PlatformUtils {
         writer.writeObjectDetached(evt.getKey());
         writer.writeObjectDetached(evt.getOldValue());
         writer.writeObjectDetached(evt.getValue());
+        writeEventType(writer, evt.getEventType());
+    }
+
+    /**
+     * Write event type to the writer.
+     * @param writer Writer.
+     * @param evtType Type of event.
+     */
+    private static void writeEventType(BinaryRawWriterEx writer, EventType 
evtType) {
+        switch (evtType){
+            case CREATED: writer.writeByte((byte) 0); break;
+            case UPDATED: writer.writeByte((byte) 1); break;
+            case REMOVED: writer.writeByte((byte) 2); break;
+            case EXPIRED: writer.writeByte((byte) 3); break;
+            default:
+                throw new IllegalArgumentException("Unknown event type: " + 
evtType);
+        }
     }
 
     /**
diff --git 
a/modules/platforms/cpp/core/include/ignite/cache/event/cache_entry_event.h 
b/modules/platforms/cpp/core/include/ignite/cache/event/cache_entry_event.h
index 14fa185..0a48c71 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/event/cache_entry_event.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/event/cache_entry_event.h
@@ -124,6 +124,9 @@ namespace ignite
 
                 this->hasOldValue = reader.TryReadObject(this->oldVal);
                 this->hasValue = reader.TryReadObject(this->val);
+                
+                // Java send an event type, we need to fetch it from the 
buffer.
+                reader.ReadInt8();
             }
 
         private:
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index 7326a82..5b56da1 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -921,7 +921,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         }
 
         /// <summary>
-        /// Craate entry.
+        /// Create entry.
         /// </summary>
         /// <param name="val">Value.</param>
         /// <returns>Entry.</returns>
@@ -945,13 +945,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         /// </summary>
         private static ICacheEntryEvent<object, object> CreateEvent<T, 
V>(ICacheEntryEvent<T,V> e)
         {
-            if (!e.HasOldValue)
-                return new CacheEntryCreateEvent<object, object>(e.Key, 
e.Value);
-
-            if (e.Value.Equals(e.OldValue))
-                return new CacheEntryRemoveEvent<object, object>(e.Key, 
e.OldValue);
-
-            return new CacheEntryUpdateEvent<object, object>(e.Key, 
e.OldValue, e.Value);
+            switch (e.EventType)
+            {
+                case CacheEntryEventType.Created:
+                    return new CacheEntryCreateEvent<object, object>(e.Key, 
e.Value);
+                case CacheEntryEventType.Updated:
+                    return new CacheEntryUpdateEvent<object, object>(e.Key, 
e.OldValue, e.Value);
+                default:
+                    return new CacheEntryRemoveEvent<object, object>(e.Key, 
e.OldValue);
+            }
         }
 
         /// <summary>
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
index 71b0580..fc93c48 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
@@ -17,6 +17,7 @@
 
 namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
 {
+    using System;
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
     using Apache.Ignite.Core.Cache.Event;
@@ -84,13 +85,18 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
 
             Debug.Assert(hasVal || hasOldVal);
 
-            if (!hasOldVal)
-                return new CacheEntryCreateEvent<TK, TV>(key, val);
-
-            if (val.Equals(oldVal))
-                return new CacheEntryRemoveEvent<TK, TV>(key, oldVal);
-
-            return new CacheEntryUpdateEvent<TK, TV>(key, oldVal, val);
+            var eventType = reader.ReadByte();
+            switch (eventType)
+            {
+                case 0:
+                    return new CacheEntryCreateEvent<TK, TV>(key, val);
+                case 1:
+                    return new CacheEntryUpdateEvent<TK, TV>(key, oldVal, val);
+                case 2:
+                    return new CacheEntryRemoveEvent<TK, TV>(key, oldVal);
+                default:
+                    throw new NotSupportedException(eventType.ToString());
+            }
         }
     }
 }

Reply via email to