java.lang.IllegalArgumentException: no product found
<p>Hi while learning spring I got stuck in following code not sure what is wrong with this code</p>

<p><strong>@Repositiry</strong></p>

<pre><code> @Repository
    public class ProductRepositiryImpl implements ProductRepositiry {

        private List&lt;Product&gt; listOfAllProducts = null;

        public ProductRepositiryImpl() {
            listOfAllProducts = new LinkedList&lt;&gt;();

            Product iphone = new Product("A1232", "iPhone", new BigDecimal(500));
            iphone.setDescription("iPhone 6s with 5.2' FHD Screen");
            iphone.setManfactuer("Apple");
            iphone.setCategory("Smart Phone");
            iphone.setUnitsInStock(699);

            listOfAllProducts.add(iphone);
        }

        @Override
        public List&lt;Product&gt; getAllProducts() {
            return listOfAllProducts;
        }

        @Override
        public Product getProductsById(String productId) {
            Product productById = null;
            for (Product product : listOfAllProducts) {
                if (product != null &amp;&amp; product.getProductId() != null &amp;&amp; product.getProductId().equals(productId)) {
                    productById = product;
                    break;
                }

                if (productById == null)
                    throw new IllegalArgumentException("no product found " + productId);

            }
            return productById;

        }

    }


**Service**



@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
ProductRepositiry productRepositiry;

@Override
public void processOrder(String productId, long count) {
    System.out.println("inside Process Order");

    Product getProductByid = productRepositiry.getProductsById(productId);
    System.out.println("get product by id");
    System.out.println(getProductByid);
    if (getProductByid.getUintsInOrder() &lt; getProductByid.getUnitsInStock()) {
        throw new IllegalArgumentException("OUT OF STOCK" + getProductByid.getUintsInOrder());
    } 
        getProductByid.setUintsInOrder(getProductByid.getUintsInOrder() - count);
}
**@controller**



@Controller
public class OrderController {

    @Autowired
    OrderService orderService;

    @RequestMapping("/order/A1234/2")
    public String processOrder() {
        System.out.println("process order");
        orderService.processOrder("A1232", 2);
        return "redirect:/product";
    }
}
</code></pre>

<p><strong>StackTrack</strong></p>

<blockquote>
  <p>SEVERE: Servlet.service() for servlet [dispatcherServlet] in context
  with path [/web_Store] threw exception [Request processing failed;
  nested exception is java.lang.IllegalArgumentException: no product
  found A1233] with root cause java.lang.IllegalArgumentException: no
  product found A1233   at
  com.webstore.repoImpl.ProductRepositiryImpl.getProductsById(ProductRepositiryImpl.java:58)
    at
  com.webstore.serviceImpl.OrderServiceImpl.processOrder(OrderServiceImpl.java:20)
    at
  com.webstore.controller.OrderController.processOrder(OrderController.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
  java.lang.reflect.Method.invoke(Unknown Source)</p>
</blockquote>

<p>In class <code>ProductRepositiryImpl</code> whenever I am trying to execute method <code>getProductsById(String productId)</code> and while debugging I get <code>productById = product;</code> holding a valid value then it is supposed to exit loop why it is still getting <code>IllegalArgumentException</code> 
any help will be appericiated</p>

<p>Best Regards</p>