[
https://issues.apache.org/jira/browse/METRON-1771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16610913#comment-16610913
]
ASF GitHub Bot commented on METRON-1771:
----------------------------------------
Github user nickwallen commented on a diff in the pull request:
https://github.com/apache/metron/pull/1190#discussion_r216726476
--- Diff:
metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchUpdateDao.java
---
@@ -133,21 +135,21 @@ public void addCommentToAlert(CommentAddRemoveRequest
request, Document latest)
Document newVersion = new Document(latest);
newVersion.getDocument().put(COMMENTS_FIELD, originalComments);
- update(newVersion, Optional.empty());
+ return update(newVersion, Optional.empty());
}
@Override
@SuppressWarnings("unchecked")
- public void removeCommentFromAlert(CommentAddRemoveRequest request)
throws IOException {
+ public Document removeCommentFromAlert(CommentAddRemoveRequest request)
throws IOException {
Document latest = retrieveLatestDao.getLatest(request.getGuid(),
request.getSensorType());
- removeCommentFromAlert(request, latest);
+ return removeCommentFromAlert(request, latest);
}
@Override
@SuppressWarnings("unchecked")
- public void removeCommentFromAlert(CommentAddRemoveRequest request,
Document latest) throws IOException {
+ public Document removeCommentFromAlert(CommentAddRemoveRequest request,
Document latest) throws IOException {
if (latest == null) {
- return;
+ return null;
--- End diff --
Same comment here. We should never see a request to remove a comment from
a doc that doesn't exist. So let's throw an exception with a message that we
can use to debug the problem.
> Update REST endpoints to support eventually consistent UI updates
> -----------------------------------------------------------------
>
> Key: METRON-1771
> URL: https://issues.apache.org/jira/browse/METRON-1771
> Project: Metron
> Issue Type: Improvement
> Reporter: Ryan Merriman
> Priority: Major
>
> Currently the REST endpoints that perform document updates either return
> true/false or nothing. This puts the responsibility of retrieving the
> updated state of the object on the client in a separate call or
> optimistically applying the changes and reverting when an update fails. This
> can be problematic if a client attempts to get the current state immediately
> after an update and the change isn't visible yet in the back end.
> Ideally they should return the updated state of the object, eliminating the
> need to look up the updated state in a separate call.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)