Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve TaskView encapsulation #1404

Open
ClemDoum opened this issue May 27, 2024 · 0 comments
Open

chore: improve TaskView encapsulation #1404

ClemDoum opened this issue May 27, 2024 · 0 comments
Assignees
Labels

Comments

@ClemDoum
Copy link
Contributor

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 only datashare-tasks can use them
  • update the TaskFactoryHelper.createTaskCallable to pass only the TaskView.properties
@ClemDoum ClemDoum added the bug label May 27, 2024
@bamthomas bamthomas changed the title chore: improve TaskView visibility chore: improve TaskView encapsulation Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Backlog
Status: Backlog
Development

No branches or pull requests

3 participants