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

Fix an NPE when a task does not exist #880

Merged
merged 1 commit into from
May 30, 2023

Conversation

trevorgerhardt
Copy link
Member

Handle the case when taskScheduler.getTaskForUser returns null so that we to prevent NullPointerExceptions which we've seen in the logs from time to time.

Handle the case when `taskScheduler.getTaskForUser` returns `null` so that we to prevent `NullPointerException`s.
@trevorgerhardt trevorgerhardt added bug t0 Time level 0: think hours labels May 30, 2023
@trevorgerhardt trevorgerhardt enabled auto-merge (squash) May 30, 2023 04:08
Copy link
Member

@abyrd abyrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to eliminate the log noise. Bigger picture, I do notice that we've got parameter validity checks split across the internal programming API (if (tasks == null) return false) and here in the HTTP API, with the innermost method only communicating boolean success/failure. Since the ACTIVE check is already "up" here in the HTTP handler we might as well put the null check here for now, but it might make sense to check everything at the innermost layer, enforcing those requirements and reporting causes on any call. Not just in this one method - we don't really have a uniform policy or approach for this, but we could start applying one the next time we're refreshing the background task handling or similar things called by the HTTP API. Java does not make it pleasant to return rich error types (without going overboard with Optional<enum DeleteTaskError> types for every single method) so this probably entails throwing meaningful exception types or at least generic exceptions with meaningful messages from all the innermost methods.

@trevorgerhardt trevorgerhardt merged commit dbcc567 into dev May 30, 2023
@trevorgerhardt trevorgerhardt deleted the fix-handle-remove-missing-task branch May 30, 2023 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug t0 Time level 0: think hours
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants