prmr / Creco

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

Dangerous nulls in AttributeExtractor #89

Closed prmr closed 10 years ago

prmr commented 10 years ago

In AttributeExtractor methods getAttributesForCategory and getAttributesForCategory you pass the result of a HashMap.get directly into a unmodifiableList. This is dangerous because the get call has null in its valid range. You should decide how to handle invalid categories (I recommend a runtime exception) and adjust the logic so it's impossible to pass a null into unmodifiableList.

asutcl commented 10 years ago

I will try to take a look at this before class.

asutcl commented 10 years ago

Would returning an empty list and Logging an error be an acceptable solution?

prmr commented 10 years ago

I think it's ok, as long as the contract is clear.