Skip to content

Commit

Permalink
[FIX] Failed concurrent creates of ISM policies should return http 409 (
Browse files Browse the repository at this point in the history
#461)

Signed-off-by: Khushboo Rajput <khushbr@amazon.com>

Signed-off-by: Khushboo Rajput <khushbr@amazon.com>
  • Loading branch information
khushbr authored Aug 12, 2022
1 parent f64c0c7 commit 2f7d009
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.opensearch.indexmanagement.indexstatemanagement.transport.action.ind
import org.apache.logging.log4j.LogManager
import org.opensearch.ExceptionsHelper
import org.opensearch.OpenSearchStatusException
import org.opensearch.ResourceAlreadyExistsException
import org.opensearch.action.ActionListener
import org.opensearch.action.DocWriteRequest
import org.opensearch.action.index.IndexRequest
Expand Down Expand Up @@ -103,7 +104,11 @@ class TransportIndexPolicyAction @Inject constructor(
}

override fun onFailure(t: Exception) {
actionListener.onFailure(ExceptionsHelper.unwrapCause(t) as Exception)
if (t is ResourceAlreadyExistsException) {
actionListener.onFailure(OpenSearchStatusException(t.localizedMessage, RestStatus.CONFLICT))
} else {
actionListener.onFailure(ExceptionsHelper.unwrapCause(t) as Exception)
}
}
})
}
Expand Down

0 comments on commit 2f7d009

Please sign in to comment.