datashare
datashare copied to clipboard
chore: improve TaskView encapsulation
Current behavior
Today, the signature of TaskFactoryHelper.createTaskCallable
is:
public class TaskFactoryHelper {
public static Callable<?> createTaskCallable(
TaskFactory factory, String name, TaskView<?> taskView, Function<Double, Void> progress
) throws UnknownTask;
}
The issue with this signature is that implementer get a TaskView
as input of their task, while they should only need the TaskView.properties
. By providing the full TaskView<?> taskView
to the implementer, we give the task implementer control over the taskView
state. In particular implementers can access setError
, setResult
which should only be called by the datashare-tasks
codebase.
Expected behavior and potential solutions
Task implementer should not be allowed to update the task state as this can have detrimental side effects.
Potential solutions:
- make
setResult
,setError
and other side effect methods package private so that onlydatashare-tasks
can use them - update the
TaskFactoryHelper.createTaskCallable
to pass only theTaskView.properties