# Java client : VersionConflictEngineException changed to ElasticsearchException?

**URL:** <https://discuss.elastic.co/t/java-client-versionconflictengineexception-changed-to-elasticsearchexception/132672>\
**Category:** Elasticsearch\
**Created:** [May 21, 2018, 3:42pm UTC](https://discuss.elastic.co/t/java-client-versionconflictengineexception-changed-to-elasticsearchexception/132672 "2018-05-21T15:42:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lionelgervaud](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lionelgervaud](https://discuss.elastic.co/u/lionelgervaud)\
**Post date:** [May 21, 2018, 3:42pm UTC](https://discuss.elastic.co/t/java-client-versionconflictengineexception-changed-to-elasticsearchexception/132672/1 "2018-05-21T15:42:31Z")

</div>

Hi everyone !  
We recently moved from version 2.x to 6.x and we noticed one unexcepted impact on our java code.  
We were catching a VersionConflictEngineException like this :

```
BulkResponse bulkReponses = bulkRequest.execute().actionGet();
if (bulkReponses.hasFailures()) {
    BulkItemResponse[] items = bulkReponses.getItems();

    for (BulkItemResponse r : items) {
        if (r.isFailed()) {
            BulkItemResponse.Failure f = r.getFailure();
            if (f.getCause() instanceof VersionConflictEngineException) {
                // do something
               ...
            }
        }
    }

```

But after upgrading, f.getCause() return a ElasticsearchException and we have to read f.getCause().getMessage() to search for "type=version\_conflict\_engine\_exception".  
Is the change of the exception type normal ?  
I noticed that, in this case, RestStatus is equal to 409 (CONFLICT). Is "version conflict" the only possible conflict or can other type of conflict used this status too ?  
I would like to find a reliable and better way to check if it's a version conflict exception than searching for a string in the exception message.  
Thanks for your help !

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [May 25, 2018, 9:16am UTC](https://discuss.elastic.co/t/java-client-versionconflictengineexception-changed-to-elasticsearchexception/132672/2 "2018-05-25T09:16:29Z")

</div>

Hi,  
quick question, have you moved your client code from Java API to the high-level REST client by any chance?

I would definitely check at the RestStatus, I am pretty sure that 409 in that case is a version conflict.

Cheers  
Luca

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 22, 2018, 9:16am UTC](https://discuss.elastic.co/t/java-client-versionconflictengineexception-changed-to-elasticsearchexception/132672/3 "2018-06-22T09:16:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
