Community
Participate
Working Groups
Code is: if (context != null) { Object categories = context.get(ICheckValidator.OPTION_CATEGORIES); if (categories instanceof Set<?>) { @SuppressWarnings("unchecked") Set<String> castedCategories = (Set<String>) categories; return castedCategories; } } That means, if someone passes OPTION_CATEGORIES a object, which is not a Set, the framework silently returns an empty set. In the else branch of we should do some error handling: * We could, if the object is an iterable, create a Set passed on that Iterable * In any case, if we don't handle the passed argument, we should log an error, throw error etc.
In the current implementation, passing an empty set of categories of no categories at all means that the checks of all categories are to be executed. Therefore, it would be counterproductive to raise an error in these cases. We could however change this policy and introduce an OPTION_CATEGORIES_ALL constant that represents this case explicitly. If this is acceptable then the case where no categories are specified can be handled as error which admittedly would result in a much more intuitive behavior.
Hi Stephan, no change of behaviour is intended. It is only a sanity check of inputs. If I would do a context.put(ICheckValidator.OPTION_CATEGORIES, new JpegImage()); the code mentioned above would just silently return an empty set without the user ever being notified that he passed something fishy. That's all that should be fixed: Complaining If something is passed, that we cannot deal with -> complain.
Closed stale issue before migration