Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-6244

Incorrect Retrying on CAS code

    XMLWordPrintable

Details

    Description

      This code leads to an infinite loop! Because `found.cas()` is constant.

      String id = "my-document";
      collection.upsert(id, JsonObject.create().put("initial", true));

      GetResult found = collection.get(id);
      JsonObject content = found.contentAsObject();
      content.put("modified", true).put("initial", false);
      while (true) {
      try

      { collection.replace(id, content, replaceOptions().cas(found.cas())); break; // if successful, break out of the retry loop }

      catch (CasMismatchException ex)

      { // don't do anything, we'll retry the loop }

      }

      Reporter: Boris
      E-mail: boris.pichugin@gmail.com

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            richard.smedley Richard Smedley
            docsite-collector Docs Site Collector
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty