I have the following code. It works fine. No exceptions etc. I am looping through a list of JPA Entity objects retrieved with a standard query (so there are not any `null` objects in the list). 

```
for (PeriodicalTable periodical : resultsP){
        stringFor.add(periodical.getReference());
        site = em.find(SiteTable.class, periodical.getSiteID());
        if (site != null && site.getPostcode() != null && !site.getPostcode().equals("")){
            tempString = site.getPostcode().replaceAll("\\s+", " ");
            periodical.setPostcode(tempString.trim());                       
            }    
        }

```

Now, I have added in an `if` statement so that one line is only fired if the object in the list being looped has a `contractManagerID` of `0`. Marked below;

```
for (PeriodicalTable periodical : resultsP){
        if(periodical.getContractManagerID()==0) //<---- HERE!!!!
        {
            stringFor.add(periodical.getReference());
        }
        site = em.find(SiteTable.class, periodical.getSiteID());           
        if (site != null && site.getPostcode() != null && !site.getPostcode().equals("")){
            tempString = site.getPostcode().replaceAll("\\s+", " ");
            periodical.setPostcode(tempString.trim());                       
            }                
        }

```

After some debugging I have isolated the exception as coming from the if statement itself (marked "HERE"), but I don't understand how that can be. We know that there are no `null` objects in the list because otherwise it wouldn't work even without the if statement, but it works fine without it. I'm completely lost.