You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/06/14 08:35:31 UTC

[13/13] james-project git commit: JAMES-2420 add a message to EventStoreFailedException to ease debugging

JAMES-2420 add a message to EventStoreFailedException to ease debugging


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e08277ec
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e08277ec
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e08277ec

Branch: refs/heads/master
Commit: e08277ecdc16fa30c19e61fa470903f10f75ca6d
Parents: 3f368fc
Author: Matthieu Baechler <ma...@apache.org>
Authored: Wed Jun 13 11:51:07 2018 +0200
Committer: benwa <bt...@linagora.com>
Committed: Thu Jun 14 15:23:13 2018 +0700

----------------------------------------------------------------------
 .../eventsourcing/eventstore/EventStoreFailedException.java      | 3 +++
 .../java/org/apache/james/eventsourcing/eventstore/History.java  | 2 +-
 .../eventsourcing/eventstore/cassandra/CassandraEventStore.java  | 2 +-
 .../eventsourcing/eventstore/memory/InMemoryEventStore.java      | 4 ++--
 4 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e08277ec/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/EventStoreFailedException.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/EventStoreFailedException.java b/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/EventStoreFailedException.java
index 93bcb2f..fb94373 100644
--- a/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/EventStoreFailedException.java
+++ b/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/EventStoreFailedException.java
@@ -20,4 +20,7 @@
 package org.apache.james.eventsourcing.eventstore;
 
 public class EventStoreFailedException extends RuntimeException {
+    public EventStoreFailedException(String message) {
+        super(message);
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e08277ec/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/History.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/History.java b/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/History.java
index 5a91306..62cc119 100644
--- a/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/History.java
+++ b/event-sourcing/event-store-api/src/main/java/org/apache/james/eventsourcing/eventstore/History.java
@@ -48,7 +48,7 @@ public class History {
 
     private History(List<Event> events) {
         if (hasEventIdDuplicates(events)) {
-            throw new EventStoreFailedException();
+            throw new EventStoreFailedException("Event History contains duplicated EventId");
         }
         this.events = events;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e08277ec/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStore.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStore.java b/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStore.java
index 0e8fd5f..7804de1 100644
--- a/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStore.java
+++ b/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraEventStore.java
@@ -53,7 +53,7 @@ public class CassandraEventStore implements EventStore {
 
         boolean success = eventStoreDao.appendAll(events).join();
         if (!success) {
-            throw new EventStoreFailedException();
+            throw new EventStoreFailedException("Concurrent update to the EventStore detected");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e08277ec/event-sourcing/event-store-memory/src/main/java/org/apache/james/eventsourcing/eventstore/memory/InMemoryEventStore.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-memory/src/main/java/org/apache/james/eventsourcing/eventstore/memory/InMemoryEventStore.java b/event-sourcing/event-store-memory/src/main/java/org/apache/james/eventsourcing/eventstore/memory/InMemoryEventStore.java
index 69ccf5f..de65ca6 100644
--- a/event-sourcing/event-store-memory/src/main/java/org/apache/james/eventsourcing/eventstore/memory/InMemoryEventStore.java
+++ b/event-sourcing/event-store-memory/src/main/java/org/apache/james/eventsourcing/eventstore/memory/InMemoryEventStore.java
@@ -69,7 +69,7 @@ public class InMemoryEventStore implements EventStore {
 
         History previousHistory = store.putIfAbsent(aggregateId, newHistory);
         if (previousHistory != null) {
-            throw new EventStoreFailedException();
+            throw new EventStoreFailedException("Concurrent update to the EventStore detected");
         }
     }
 
@@ -80,7 +80,7 @@ public class InMemoryEventStore implements EventStore {
 
         boolean isReplaced = store.replace(aggregateId, currentHistory, updatedHistory);
         if (!isReplaced) {
-            throw new EventStoreFailedException();
+            throw new EventStoreFailedException("Concurrent update to the EventStore detected");
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org