Program: 49402
Project: 49402
Buggy source:
/** 
 * Create any pools that need to be created for the given subscription. In some scenarios, due to attribute changes, pools may need to be created even though pools already exist for the subscription. A list of pre-existing pools for the given sub are provided to help this method determine if something needs to be done or not. For a genuine new subscription, the existing pools list will be empty.
 * @param sub
 * @param existingPools
 * @return
 */
public List<Pool> createPools(Subscription sub,List<Pool> existingPools){
  log.info("String_Node_Str" + sub);
  PoolHelper helper=new PoolHelper(this.poolManager,null);
  Product sku=prodCurator.lookupById(sub.getOwner(),sub.getProduct().getId());
  sub.setProduct(sku);
  List<Pool> pools=new LinkedList<Pool>();
  Map<String,String> attributes=helper.getFlattenedAttributes(sku);
  long quantity=calculateQuantity(sub);
  if (!hasMasterPool(existingPools)) {
    Pool newPool=new Pool(sub.getOwner(),sku,new HashSet<Product>(),quantity,sub.getStartDate(),sub.getEndDate(),sub.getContractNumber(),sub.getAccountNumber(),sub.getOrderNumber());
    for (    Product pp : sub.getProvidedProducts()) {
      newPool.addProvidedProduct(prodCurator.lookupById(sub.getOwner(),pp.getId()));
    }
    if (sub.getDerivedProvidedProducts() != null) {
      newPool.getDerivedProvidedProducts().addAll(sub.getDerivedProvidedProducts());
    }
    if (sub.getDerivedProduct() != null) {
      newPool.setDerivedProduct(sub.getDerivedProduct());
    }
    for (    Branding b : sub.getBranding()) {
      newPool.getBranding().add(new Branding(b.getProductId(),b.getType(),b.getName()));
    }
    newPool.setSourceSubscription(new SourceSubscription(sub.getId(),"String_Node_Str"));
    ProductAttribute virtAtt=sku.getAttribute("String_Node_Str");
    if (virtAtt != null && virtAtt.getValue() != null && !virtAtt.getValue().equals("String_Node_Str")) {
      newPool.addAttribute(new org.candlepin.model.PoolAttribute("String_Node_Str",virtAtt.getValue()));
    }
    pools.add(newPool);
  }
  boolean hostLimited=attributes.containsKey("String_Node_Str") && attributes.get("String_Node_Str").equals("String_Node_Str");
  if (attributes.containsKey("String_Node_Str") && !hasBonusPool(existingPools)) {
    HashMap<String,String> virtAttributes=new HashMap<String,String>();
    virtAttributes.put("String_Node_Str","String_Node_Str");
    virtAttributes.put("String_Node_Str","String_Node_Str");
    virtAttributes.put("String_Node_Str","String_Node_Str");
    if (hostLimited || config.getBoolean(ConfigProperties.STANDALONE)) {
      virtAttributes.put("String_Node_Str","String_Node_Str");
    }
    virtAttributes.put("String_Node_Str","String_Node_Str");
    String virtQuantity=getVirtQuantity(attributes.get("String_Node_Str"),quantity);
    if (virtQuantity != null) {
      if (sub.getDerivedProduct() != null) {
        sku=sub.getDerivedProduct();
      }
      Pool derivedPool=helper.createPool(sub,sku,virtQuantity,virtAttributes,prodCurator);
      derivedPool.setSourceSubscription(new SourceSubscription(sub.getId(),"String_Node_Str"));
      pools.add(derivedPool);
    }
  }
  return pools;
}

Fixed version (ground truth):
/** 
 * Create any pools that need to be created for the given subscription. In some scenarios, due to attribute changes, pools may need to be created even though pools already exist for the subscription. A list of pre-existing pools for the given sub are provided to help this method determine if something needs to be done or not. For a genuine new subscription, the existing pools list will be empty.
 * @param sub
 * @param existingPools
 * @return
 */
public List<Pool> createPools(Subscription sub,List<Pool> existingPools){
  log.info("String_Node_Str" + sub);
  PoolHelper helper=new PoolHelper(this.poolManager,null);
  Product sku=prodCurator.lookupById(sub.getOwner(),sub.getProduct().getId());
  sub.setProduct(sku);
  List<Pool> pools=new LinkedList<Pool>();
  Map<String,String> attributes=helper.getFlattenedAttributes(sku);
  long quantity=calculateQuantity(sub);
  if (!hasMasterPool(existingPools)) {
    Pool newPool=new Pool(sub.getOwner(),sku,new HashSet<Product>(),quantity,sub.getStartDate(),sub.getEndDate(),sub.getContractNumber(),sub.getAccountNumber(),sub.getOrderNumber());
    for (    Product pp : sub.getProvidedProducts()) {
      newPool.addProvidedProduct(prodCurator.lookupById(sub.getOwner(),pp.getId()));
    }
    if (sub.getDerivedProvidedProducts() != null) {
      for (      Product pp : sub.getDerivedProvidedProducts()) {
        newPool.addDerivedProvidedProduct(prodCurator.lookupById(sub.getOwner(),pp.getId()));
      }
    }
    if (sub.getDerivedProduct() != null) {
      newPool.setDerivedProduct(prodCurator.lookupById(sub.getOwner(),sub.getDerivedProduct().getId()));
    }
    for (    Branding b : sub.getBranding()) {
      newPool.getBranding().add(new Branding(b.getProductId(),b.getType(),b.getName()));
    }
    newPool.setSourceSubscription(new SourceSubscription(sub.getId(),"String_Node_Str"));
    ProductAttribute virtAtt=sku.getAttribute("String_Node_Str");
    if (virtAtt != null && virtAtt.getValue() != null && !virtAtt.getValue().equals("String_Node_Str")) {
      newPool.addAttribute(new org.candlepin.model.PoolAttribute("String_Node_Str",virtAtt.getValue()));
    }
    pools.add(newPool);
  }
  boolean hostLimited=attributes.containsKey("String_Node_Str") && attributes.get("String_Node_Str").equals("String_Node_Str");
  if (attributes.containsKey("String_Node_Str") && !hasBonusPool(existingPools)) {
    HashMap<String,String> virtAttributes=new HashMap<String,String>();
    virtAttributes.put("String_Node_Str","String_Node_Str");
    virtAttributes.put("String_Node_Str","String_Node_Str");
    virtAttributes.put("String_Node_Str","String_Node_Str");
    if (hostLimited || config.getBoolean(ConfigProperties.STANDALONE)) {
      virtAttributes.put("String_Node_Str","String_Node_Str");
    }
    virtAttributes.put("String_Node_Str","String_Node_Str");
    String virtQuantity=getVirtQuantity(attributes.get("String_Node_Str"),quantity);
    if (virtQuantity != null) {
      if (sub.getDerivedProduct() != null) {
        sku=prodCurator.lookupById(sub.getOwner(),sub.getDerivedProduct().getId());
      }
      Pool derivedPool=helper.createPool(sub,sku,virtQuantity,virtAttributes,prodCurator);
      derivedPool.setSourceSubscription(new SourceSubscription(sub.getId(),"String_Node_Str"));
      pools.add(derivedPool);
    }
  }
  return pools;
}