Program: 49407
Project: 49407
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,this.productCache,null);
  List<Pool> pools=new LinkedList<Pool>();
  Map<String,String> attributes=helper.getFlattenedAttributes(sub.getProduct());
  long quantity=calculateQuantity(sub);
  if (!hasMasterPool(existingPools)) {
    Pool newPool=new Pool(sub.getOwner(),sub.getProduct(),sub.getProvidedProducts(),quantity,sub.getStartDate(),sub.getEndDate(),sub.getContractNumber(),sub.getAccountNumber(),sub.getOrderNumber());
    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=sub.getProduct().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) {
      Product poolProduct=sub.getProduct();
      if (sub.getDerivedProduct() != null) {
        poolProduct=sub.getDerivedProduct();
      }
      Pool derivedPool=helper.createPool(sub,poolProduct,virtQuantity,virtAttributes);
      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,this.productCache,null);
  List<Pool> pools=new LinkedList<Pool>();
  Map<String,String> attributes=helper.getFlattenedAttributes(sub.getProduct());
  long quantity=calculateQuantity(sub);
  if (!hasMasterPool(existingPools)) {
    Pool newPool=new Pool(sub.getOwner(),sub.getProduct(),new HashSet<Product>(sub.getProvidedProducts()),quantity,sub.getStartDate(),sub.getEndDate(),sub.getContractNumber(),sub.getAccountNumber(),sub.getOrderNumber());
    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=sub.getProduct().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) {
      Product poolProduct=sub.getProduct();
      if (sub.getDerivedProduct() != null) {
        poolProduct=sub.getDerivedProduct();
      }
      Pool derivedPool=helper.createPool(sub,poolProduct,virtQuantity,virtAttributes);
      derivedPool.setSourceSubscription(new SourceSubscription(sub.getId(),"String_Node_Str"));
      pools.add(derivedPool);
    }
  }
  return pools;
}