Source:
<code>private DeveloperProducts getDevProductMap(Owner owner, String sku) { Collection<? extends ProductInfo> productsByIds = this.productAdapter .getProductsByIds(owner.getKey(), Arrays.asList(sku)); Collection<String> devProductIds = new ArrayList<>(); if (productsByIds.iterator().hasNext()) { ProductInfo devProduct = productsByIds.iterator().next(); devProductIds.add(devProduct.getId()); <START> if (!devProduct.getProvidedProducts().isEmpty()) { <END> devProductIds.addAll( devProduct.getProvidedProducts() .stream() .map(p -> p.getId()) .collect(Collectors.toList()) ); } } log.debug("Importing products for dev pool resolution..."); ImportedEntityCompiler compiler = new ImportedEntityCompiler(); compiler.addProducts(this.productAdapter.getProductsByIds(owner.getKey(), devProductIds)); Map<String, ? extends ProductInfo> productMap = compiler.getProducts(); Map<String, ? extends ContentInfo> contentMap = compiler.getContent(); log.debug("Importing content...", contentMap.size()); Map<String, Content> importedContent = this.contentManager .importContent(owner, contentMap, productMap.keySet()) .getImportedEntities(); log.debug("Importing product(s)...", productMap.size()); Map<String, Product> importedProducts = this.productManager .importProducts(owner, productMap, importedContent) .getImportedEntities(); log.debug("Resolved dev product(s) for sku: {}", productMap.size(), sku); return new DeveloperProducts(sku, importedProducts); }</code><technical_language>This block is a bit dangerous, innate control devProduct returns a non-null not. Plus, do some optimization avoid instantiating a new collection, populate: Collection<? extends ProductInfo> provided = devProduct.getProvidedProducts(); if (provided != null) { provided.forEach(product -> { if (product != null) { devProductIds.add(product.getId()); } }); }</technical_language>

Target:
private DeveloperProducts getDevProductMap(Owner owner, String sku) { Collection<? extends ProductInfo> productsByIds = this.productAdapter .getProductsByIds(owner.getKey(), Arrays.asList(sku)); Collection<String> devProductIds = new ArrayList<>(); if (productsByIds.iterator().hasNext()) { ProductInfo devProduct = productsByIds.iterator().next(); devProductIds.add(devProduct.getId()); Collection<? extends ProductInfo> provided = devProduct.getProvidedProducts(); if (provided != null) { provided.forEach(product -> { if (product != null) { devProductIds.add(product.getId()); } }); } } log.debug("Importing products for dev pool resolution..."); ImportedEntityCompiler compiler = new ImportedEntityCompiler(); compiler.addProducts(this.productAdapter.getProductsByIds(owner.getKey(), devProductIds)); Map<String, ? extends ProductInfo> productMap = compiler.getProducts(); Map<String, ? extends ContentInfo> contentMap = compiler.getContent(); log.debug("Importing content...", contentMap.size()); Map<String, Content> importedContent = this.contentManager .importContent(owner, contentMap, productMap.keySet()) .getImportedEntities(); log.debug("Importing product(s)...", productMap.size()); Map<String, Product> importedProducts = this.productManager .importProducts(owner, productMap, importedContent) .getImportedEntities(); log.debug("Resolved dev product(s) for sku: {}", productMap.size(), sku); return new DeveloperProducts(sku, importedProducts); }