IGNITE-12163 .NET: CacheEntryEventType.Removed is not being risen - Fixes #6862.
(cherry picked from commit 3110d72)
Signed-off-by: Ivan Rakov <irakov@apache.org>
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 12f70dd..e08b79e 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
@@ -62,6 +62,7 @@
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 @@
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 @@
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 @@
}
/// <summary>
- /// Craate entry.
+ /// Create entry.
/// </summary>
/// <param name="val">Value.</param>
/// <returns>Entry.</returns>
@@ -945,13 +945,15 @@
/// </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 @@
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());
+ }
}
}
}