Bug 473258 - AbstractCheckValidator.getCategoriesFromContext should do argument validation
Summary: AbstractCheckValidator.getCategoriesFromContext should do argument validation
Status: CLOSED WONTFIX
Alias: None
Product: Sphinx
Classification: Automotive
Component: Core (show other bugs)
Version: 0.9.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Stephan Eberle CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-22 03:49 EDT by Andreas Graf CLA
Modified: 2024-05-07 00:11 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Graf CLA 2015-07-22 03:49:57 EDT
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.
Comment 1 Stephan Eberle CLA 2015-07-22 06:07:46 EDT
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.
Comment 2 Andreas Graf CLA 2015-07-23 10:18:18 EDT
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.
Comment 3 Balazs Grill CLA 2024-05-07 00:11:38 EDT
Closed stale issue before migration