When a RandomRecommendations engine can't find a random recommendation, an Assertion fails raising an IllegalArgument exception. This is a problem because it is not obvious why the exception happened and because it may happen due to runtime conditions.
it may happen that the the selector (a RandomNodeSelector) couldn't find a node so it will return a null node which will not respect the NotNull assertion on SimpleContext.allow method which is called later.
It is easy to replicate the case: just extend the RandomRecommendations engine with a NodeInclusionPolicy that can't be respected (provide as an example a not existing Label).
But as i told before, it may happen at runtime too because it may happen that nodes that the inclusion policy would accept, would have been removed during runtime operations on the graph, so i think that checking if the node is null, should be performed immediately after the selector.selectNode call and it should be ok that the RandomRecommendations could not return recommendations without exceptions.
When a RandomRecommendations engine can't find a random recommendation, an Assertion fails raising an IllegalArgument exception. This is a problem because it is not obvious why the exception happened and because it may happen due to runtime conditions.
This is line 68 in RandomRecommendations:
it may happen that the the selector (a RandomNodeSelector) couldn't find a node so it will return a null node which will not respect the NotNull assertion on SimpleContext.allow method which is called later.
It is easy to replicate the case: just extend the RandomRecommendations engine with a NodeInclusionPolicy that can't be respected (provide as an example a not existing Label).
But as i told before, it may happen at runtime too because it may happen that nodes that the inclusion policy would accept, would have been removed during runtime operations on the graph, so i think that checking if the node is null, should be performed immediately after the selector.selectNode call and it should be ok that the RandomRecommendations could not return recommendations without exceptions.