Skip to content

Commit

Permalink
Change client listener to receive events even without oldValue
Browse files Browse the repository at this point in the history
  • Loading branch information
wburns committed Oct 9, 2023
1 parent cbaeab0 commit 2342181
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testRemovedEvent() {
withClientListener(l, remote -> {
l.expectNoEvents();
remote.remove(1);
l.expectNoEvents();
l.expectOnlyRemovedEvent(1);
remote.put(1, "one");
l.expectOnlyCreatedEvent(1);
remote.remove(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void testEventReceiveBasic() {
withClientListener(l, remote -> {
l.expectNoEvents();
remote.remove(1);
l.expectNoEvents();
l.expectOnlyRemovedEvent(1);
remote.put(1, "one");
assertEquals("one", getEmbeddedCache().get(1));
l.expectOnlyCreatedEvent(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,8 @@ boolean isSendEvent(CacheEntryEvent<byte[], byte[]> event) {
switch (event.getType()) {
case CACHE_ENTRY_CREATED:
case CACHE_ENTRY_MODIFIED:
return !event.isPre();
case CACHE_ENTRY_REMOVED:
CacheEntryRemovedEvent removedEvent = (CacheEntryRemovedEvent) event;
return !event.isPre() && removedEvent.getOldValue() != null;
return !event.isPre();
case CACHE_ENTRY_EXPIRED:
return true;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void testCustomEvents(Method m) {
eventListener.expectNoEvents(Optional.empty());
byte[] key = k(m);
client().remove(key);
eventListener.expectNoEvents(Optional.empty());
eventListener.expectSingleCustomEvent(cache, addLengthPrefix(key));
byte[] value = v(m);
client().put(key, 0, 0, value);
eventListener.expectSingleCustomEvent(cache, addLengthPrefix(key, value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testRemovedEvent(Method m) {
eventListener.expectNoEvents(Optional.empty());
byte[] key = k(m);
client().remove(key);
eventListener.expectNoEvents(Optional.empty());
eventListener.expectOnlyRemovedEvent(cache, key);
client().put(key, 0, 0, v(m));
eventListener.expectOnlyCreatedEvent(cache, key);
client().remove(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testRemovedEvent(ProtocolVersion protocolVersion) {
new EventLogListener<>(remoteCache(protocolVersion)).accept((l, remote) -> {
l.expectNoEvents();
remote.remove(1);
l.expectNoEvents();
l.expectOnlyRemovedEvent(1);
remote.put(1, "one");
l.expectOnlyCreatedEvent(1);
remote.remove(1);
Expand Down

0 comments on commit 2342181

Please sign in to comment.