prmr / Creco

Recommendation System for Consumer Products
Apache License 2.0
6 stars 2 forks source link

NullPointerException when sorting laptops by weight #67

Closed forgues closed 10 years ago

forgues commented 10 years ago

When I search for laptops and only select weight as a specification, I get a null pointer exception. I'm assuming this is because not all products have a weight, and the logic is attempting to sort all products by their weight even if they don't have one.

Here is the line which throws the null pointer: if(pProductList.get(j).getAttribute(pAttrId).getTypedValue().getNumeric() < pProductList.get(j-1).getAttribute(pAttrId).getTypedValue().getNumeric())

and here is the stack trace:

java.lang.NullPointerException: null at ca.mcgill.cs.creco.util.RankedFeaturesProducts.directionSensitiveProductSort(RankedFeaturesProducts.java:169) at ca.mcgill.cs.creco.util.RankedFeaturesProducts.FeatureSensitiveRanking(RankedFeaturesProducts.java:85) at ca.mcgill.cs.creco.web.controller.SearchController.sendCurrentFeatureList(SearchController.java:623)

MariamN commented 10 years ago

pushed to master