Inconsistent expectations on TimeseriesStorageManager.get() with null return values
Description
Acceptance / Success Criteria
Attachments
related to
Activity

Alex May March 17, 2023 at 5:02 PM
PR:
I originally changed it to use an Optional, but as I was updating the consumers, every update ended up using .orElseThrow()
since other StorageException
s were expected within the same code blocks.

Alex May March 15, 2023 at 4:32 PM
I forgot to add a comment here, but I discussed this with Chandra and my plan is to change the interface to return an Optional and adjust consumer behavior, so essentially option 2.

DJ Gregor March 15, 2023 at 2:08 AMEdited
you asked about whether we can close this ticket. Although we are in the process of removing one of the cases that can trigger it with , the bug still exists and can be triggered by misconfiguration and other runtime problems.
Anytime this else
statement is reached …
… get()
will return a null
and there are still a pile of consumers that won’t check for that case and will get a NullPointerException
. We fixed one of the consumers in but there are still half a dozen others.
I think the key thing is to clarify whether implementations of TimeseriesStorageManager.get()
can return nulls and based on the answer, I think there are (at least) two paths to go down:
If we decide nulls are not allowed,
Add a comment to the interface that a
null
will never be returned (or is there an annotation to reflect this?), andChange
TimeseriesStorageManagerImpl.get()
to do either of these:Return something like a default or no-op
TimeseriesStorage
implementation, orThrow an exception if there is no
TimeseriesStorage
implementation available (including similar details to the existing warning log message).
If we decide nulls are allowed,
Mark the interface as
@Nullable
, andFix all of the consumers to do the appropriate thing if a null is returned.
I think 1 is definitely easier, but this type of interface design decision is not a strength of mine, so don’t take my word on which way to go.
Details
Assignee
Alex MayAlex MayReporter
DJ GregorDJ GregorHB Grooming Date
Jan 31, 2023HB Backlog Status
Refined BacklogSprint
NoneFix versions
Priority
Medium
Details
Details
Assignee

Reporter

HB Grooming Date
HB Backlog Status
Sprint
Fix versions
Priority
PagerDuty
PagerDuty Incident
PagerDuty
PagerDuty Incident
PagerDuty

The interface doesn’t imply whether
get()
can return anull
or not:The primary (sole?) implementation can return a
null
(although it does try to add aTimeSeriesStorage
if there isn’t one):–
Should this be marked as
@Nullable
on the interface (and the consumers adjusted appropriately)? Or should the implementation be changed to never return anull
and instead a no-op implementation?Many of the consumers assume that
get()
will not return anull
for example:Which leads to things like:
Other consumers: