Program: 49278
Project: 49278
Buggy source:
/** 
 * Updates the specified content instance, creating a new version of the content as necessary. The content instance returned by this method is not guaranteed to be the same instance passed in. As such, once this method has been called, callers should only use the instance output by this method.
 * @param entity The content entity to update
 * @param owner The owner for which to update the content
 * @param regenerateEntitlementCerts Whether or not changes made to the content should trigger the regeneration of entitlement certificates for affected consumers
 * @throws IllegalStateException if this method is called with an entity does not exist in the backing database for the given owner
 * @throws IllegalArgumentException if either the provided content entity or owner are null
 * @return the updated content entity, or a new content entity
 */
@Transactional public Content updateContent(Content entity,ContentData update,Owner owner,boolean regenerateEntitlementCerts){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (update == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (owner == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  log.debug("String_Node_Str",entity,owner);
  entity=this.contentCurator.lookupById(owner,entity.getId());
  if (entity == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (!entity.isChangedBy(update)) {
    return entity;
  }
  Content updated=this.applyContentChanges((Content)entity.clone(),update,owner);
  List<Content> alternateVersions=this.contentCurator.getContentByVersion(update.getId(),updated.hashCode()).list();
  log.debug("String_Node_Str",alternateVersions.size());
  for (  Content alt : alternateVersions) {
    if (alt.equals(updated)) {
      log.debug("String_Node_Str",updated,alt);
      List<Product> affectedProducts=this.productCurator.getProductsWithContent(owner,Arrays.asList(updated.getId()));
      List<Owner> owners=Arrays.asList(owner);
      updated=this.ownerContentCurator.updateOwnerContentReferences(updated,alt,owners);
      ContentData cdata=updated.toDTO();
      for (      Product product : affectedProducts) {
        ProductData pdata=product.toDTO();
        ProductContentData pcd=pdata.getProductContent(updated.getId());
        if (pcd != null) {
          pcd.setContent(cdata);
          this.productManager.updateProduct(product,pdata,owner,regenerateEntitlementCerts);
        }
      }
      return updated;
    }
  }
  if (this.ownerContentCurator.getOwnerCount(updated) == 1) {
    log.debug("String_Node_Str",updated);
    updated=this.contentCurator.merge(updated);
    if (regenerateEntitlementCerts) {
      this.entitlementCertGenerator.regenerateCertificatesOf(this.productCurator.getProductsWithContent(Arrays.asList(updated.getUuid())),true);
    }
    return updated;
  }
  log.debug("String_Node_Str",updated);
  List<Owner> owners=Arrays.asList(owner);
  updated.setUuid(null);
  List<Product> affectedProducts=this.productCurator.getProductsWithContent(owner,Arrays.asList(updated.getId()));
  updated=this.contentCurator.create(updated);
  ContentData cdata=updated.toDTO();
  for (  Product product : affectedProducts) {
    ProductData pdata=product.toDTO();
    ProductContentData pcd=pdata.getProductContent(updated.getId());
    if (pcd != null) {
      pcd.setContent(cdata);
      this.productManager.updateProduct(product,pdata,owner,regenerateEntitlementCerts);
    }
    this.productManager.updateProduct(product,pdata,owner,regenerateEntitlementCerts);
  }
  return this.ownerContentCurator.updateOwnerContentReferences(entity,updated,owners);
}

Fixed version (ground truth):
/** 
 * Updates the specified content instance, creating a new version of the content as necessary. The content instance returned by this method is not guaranteed to be the same instance passed in. As such, once this method has been called, callers should only use the instance output by this method.
 * @param entity The content entity to update
 * @param owner The owner for which to update the content
 * @param regenerateEntitlementCerts Whether or not changes made to the content should trigger the regeneration of entitlement certificates for affected consumers
 * @throws IllegalStateException if this method is called with an entity does not exist in the backing database for the given owner
 * @throws IllegalArgumentException if either the provided content entity or owner are null
 * @return the updated content entity, or a new content entity
 */
@Transactional public Content updateContent(Content entity,ContentData update,Owner owner,boolean regenerateEntitlementCerts){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (update == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (owner == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  log.debug("String_Node_Str",entity,owner);
  entity=this.ownerContentCurator.getContentById(owner,entity.getId());
  if (entity == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (!entity.isChangedBy(update)) {
    return entity;
  }
  Content updated=this.applyContentChanges((Content)entity.clone(),update,owner);
  List<Content> alternateVersions=this.contentCurator.getContentByVersion(update.getId(),updated.hashCode()).list();
  log.debug("String_Node_Str",alternateVersions.size());
  for (  Content alt : alternateVersions) {
    if (alt.equals(updated)) {
      log.debug("String_Node_Str",updated,alt);
      List<Product> affectedProducts=this.productCurator.getProductsWithContent(owner,Arrays.asList(updated.getId()));
      List<Owner> owners=Arrays.asList(owner);
      updated=this.ownerContentCurator.updateOwnerContentReferences(updated,alt,owners);
      ContentData cdata=updated.toDTO();
      for (      Product product : affectedProducts) {
        ProductData pdata=product.toDTO();
        ProductContentData pcd=pdata.getProductContent(updated.getId());
        if (pcd != null) {
          pcd.setContent(cdata);
          this.productManager.updateProduct(product,pdata,owner,regenerateEntitlementCerts);
        }
      }
      return updated;
    }
  }
  if (this.ownerContentCurator.getOwnerCount(updated) == 1) {
    log.debug("String_Node_Str",updated);
    updated=this.contentCurator.merge(updated);
    if (regenerateEntitlementCerts) {
      List<Product> affectedProducts=this.productCurator.getProductsWithContent(Arrays.asList(updated.getUuid()));
      this.entitlementCertGenerator.regenerateCertificatesOf(Arrays.asList(owner),affectedProducts,true);
    }
    return updated;
  }
  log.debug("String_Node_Str",updated);
  updated.setUuid(null);
  List<Product> affectedProducts=this.productCurator.getProductsWithContent(owner,Arrays.asList(updated.getId()));
  updated=this.contentCurator.create(updated);
  ContentData cdata=updated.toDTO();
  for (  Product product : affectedProducts) {
    ProductData pdata=product.toDTO();
    ProductContentData pcd=pdata.getProductContent(updated.getId());
    if (pcd != null) {
      pcd.setContent(cdata);
      this.productManager.updateProduct(product,pdata,owner,regenerateEntitlementCerts);
    }
  }
  return this.ownerContentCurator.updateOwnerContentReferences(entity,updated,Arrays.asList(owner));
}