adamdebreceni commented on a change in pull request #807:
URL: https://github.com/apache/nifi-minifi-cpp/pull/807#discussion_r452725222



##########
File path: libminifi/src/FlowFileRecord.cpp
##########
@@ -118,28 +110,27 @@ FlowFileRecord::~FlowFileRecord() {
     logger_->log_debug("Delete FlowFile UUID %s", uuidStr_);
   else
     logger_->log_debug("Delete SnapShot FlowFile UUID %s", uuidStr_);
-  if (claim_) {
-    releaseClaim(claim_);
-  } else {
+
+  if (!claim_) {
     logger_->log_debug("Claim is null ptr for %s", uuidStr_);
   }
 
+  claim_.set(*this, nullptr);
+
   // Disown stash claims
-  for (const auto &stashPair : stashedContent_) {
-    releaseClaim(stashPair.second);
+  for (auto &stashPair : stashedContent_) {
+    auto& stashClaim = stashPair.second;
+    stashClaim.set(*this, nullptr);
   }
 }
 
 void FlowFileRecord::releaseClaim(std::shared_ptr<ResourceClaim> claim) {
   // Decrease the flow file record owned count for the resource claim
-  claim_->decreaseFlowFileRecordOwnedCount();
-  std::string value;
-  logger_->log_debug("Delete Resource Claim %s, %s, attempt %llu", 
getUUIDStr(), claim_->getContentFullPath(), 
claim_->getFlowFileRecordOwnedCount());
-  if (claim_->getFlowFileRecordOwnedCount() <= 0) {
-    // we cannot rely on the stored variable here since we aren't guaranteed 
atomicity
-    if (flow_repository_ != nullptr && !flow_repository_->Get(uuidStr_, 
value)) {
-      logger_->log_debug("Delete Resource Claim %s", 
claim_->getContentFullPath());
-      content_repo_->remove(claim_);
+  claim->decreaseFlowFileRecordOwnedCount();
+  logger_->log_debug("Detaching Resource Claim %s, %s, attempt %llu", 
getUUIDStr(), claim->getContentFullPath(), 
claim->getFlowFileRecordOwnedCount());
+  if (content_repo_) {
+    if (content_repo_->removeIfOrphaned(claim)) {

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to