How are you initializing the Product class? And it would be good if you made this change to avoid breaking the program since category can be null.
Add this "?" here