Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-6795

Fix bug in CouchbaseMapCacheClient.java which prevents new Couchbase Object from being created

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.11.0
    • Extensions

    Description

      The function below has a bug: 

      @Override
       public <K, V> boolean replace(AtomicCacheEntry<K, V, Long> entry, Serializer<K> keySerializer, Serializer<V> valueSerializer) throws IOException {
       final Long revision = entry.getRevision().orElse(0L);
       final String docId = toDocumentId(entry.getKey(), keySerializer);
       final Document doc = toDocument(docId, entry.getValue(), valueSerializer, revision);
       try {
       if (revision < 0) {
       // If the document does not exist yet, try to create one.
       try {
       bucket.insert(doc);
       return true;
       } catch (DocumentAlreadyExistsException e) {
       return false;
       }
      final Long revision = entry.getRevision().orElse(0L);

      should be

      final Long revision = entry.getRevision().orElse(-1L);

      otherwise a new document never gets created in the check

      if (revision < 0) {
       // If the document does not exist yet, try to create one.
       try {
       bucket.insert(doc);
       return true;
       } catch (DocumentAlreadyExistsException e) {
       return false;
       }

      I have tested the code change locally and it works properly...

       

      --John

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            fortinj66 John E Fortin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h
                1h