Graylog2 / Graylog2/graylog2-server

Refactor TimeRange classes

Open
#2,387 0 comments 1 reaction 0 assignees View on GitHub
improvement infrastructure triaged
Dominant language
Java
Stars
8.1k
Forks
1.1k
Avg merge
1d 20h
Merged PRs (30d)
217

Description

The non-absolute time range objects used for searches currently reevaluate their start and end dates on each method call.
This can lead to strange behavior (as in #2382) where even the same instance of a 60 second relative range returns a different interval when asked repeatedly.

In some other cases (#2335) we need this behavior because the instances stay in memory for a long time, but we want the searches to reflect the time range anchored at `now`.

One option would be to refactor the time range creators to default to `AbsoluteRange` creating instances that never change their interval.
If needed code can also create "reevaluating" instances using different methods which stand out a little more.

``` java
// stays fixed
AbsoluteRange a = RelativeRange.create(60);
// re-evaluates every time
RelativeRange r = RelativeRange.createMoving(60);
```

related to #2382 #2335 #2301

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.