Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 181
Add feature flag to stop defaulting null datetime filter args to current time#1067
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b0e5a144f2ebc8994788b6926015f48b6ebFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,25 @@ | ||
| package com.hubspot.jinjava.features; | ||
| import com.hubspot.jinjava.interpret.Context; | ||
| import java.time.LocalDateTime; | ||
| import java.time.ZonedDateTime; | ||
| public class DateTimeFeatureActivationStrategy implements FeatureActivationStrategy { | ||
| private final LocalDateTime activateAt; | ||
| private final ZonedDateTime activateAt; | ||
| public static DateTimeFeatureActivationStrategy of(LocalDateTime activateAt) { | ||
| public static DateTimeFeatureActivationStrategy of(ZonedDateTime activateAt) { | ||
| return new DateTimeFeatureActivationStrategy(activateAt); | ||
| } | ||
| private DateTimeFeatureActivationStrategy(LocalDateTime activateAt) { | ||
| private DateTimeFeatureActivationStrategy(ZonedDateTime activateAt) { | ||
| this.activateAt = activateAt; | ||
| } | ||
| @Override | ||
| public boolean isActive(Context context) { | ||
| return LocalDateTime.now().isAfter(activateAt); | ||
| return ZonedDateTime.now().isAfter(activateAt); | ||
| } | ||
| public LocalDateTime getActivateAt() { | ||
| public ZonedDateTime getActivateAt() { | ||
| return activateAt; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,6 +10,7 @@ | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.time.Duration; | ||
| import org.junit.Before; | ||
| import org.junit.Ignore; | ||
| import org.junit.Test; | ||
| public class EscapeFilterTest extends BaseInterpretingTest { | ||
| @@ -41,7 +42,7 @@ public void testSafeStringCanBeEscaped() { | ||
| .isInstanceOf(SafeString.class); | ||
| } | ||
| @Test | ||
| @Ignore | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sometimes this is not faster when building. | ||
| public void testNewStringReplaceIsFaster() { | ||
| String html = fixture("filter/blog.html").substring(0, 100_000); | ||
| Stopwatch oldStopWatch = Stopwatch.createStarted(); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not safe casts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, true, but for this particular feature it will be.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the feature-flag is changed to
FeatureStrategies.ACTIVE, this will blow up at runtimeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But for compatibility reasons, this has to return a valid date. So it's either a casting exception or some other exception.