feat!: Replace TimeSpan with FiniteDuration#2057
Open
farmdawgnation wants to merge 11 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove TimeSpan, TimeSpanBuilder, related implicits, and ConvertableToDate from TimeHelpers. Add formatDuration for human-readable duration strings. Tighten Joda-Time import to only DateTime (still needed for DateTimeExtension). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ftSession Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…let, and related HTTP files Fixes TimeSpan compilation errors across LiftRules.scala, LiftServlet.scala, LiftMerge.scala, SessionMaster.scala, ResourceServer.scala, and HttpAuthentication.scala. Duration-typed Long fields now use .toMillis, and FactoryMaker types use FiniteDuration directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove all TimeSpan-based test blocks ("A TimeSpan" can/should, old
"Duration builders"), the TimeAmountsGen trait, and the Period/DateTime
joda imports. Add "Duration builder syntax" and "formatDuration" specs
using scala.concurrent.duration.FiniteDuration. Also fix ScheduleSpec
to use 10.millis instead of TimeSpan(10) now that Schedule.schedule
takes FiniteDuration.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Updated Scaladoc on LAPinger.schedule to remove stale TimeSpan reference (replaced with "delay milliseconds") and fixed an unclosed <code> HTML tag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR modernizes Lift’s time/scheduling utilities by removing the custom TimeSpan API surface and standardizing on Scala’s FiniteDuration (and explicit millisecond Longs where required), with associated updates across HTTP, Comet, JS command helpers, and tests.
Changes:
- Replaced
TimeSpan-based scheduling/duration APIs withFiniteDuration(and.toMillisconversions when interacting with millisecondLongAPIs). - Removed deprecated/ambiguous time helper types and introduced a simplified
formatDuration(millis: Long)utility. - Updated affected tests and call sites to use Scala duration DSL (
10.millis,30.seconds, etc.).
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| web/webkit/src/main/scala/net/liftweb/http/SessionMaster.scala | Converts session cleanup threshold math to use FiniteDuration.toMillis. |
| web/webkit/src/main/scala/net/liftweb/http/ResourceServer.scala | Updates cache header expiration calculations to use FiniteDuration.toMillis. |
| web/webkit/src/main/scala/net/liftweb/http/NamedCometActorTrait.scala | Updates Comet actor lifespan signature to Box[FiniteDuration]. |
| web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala | Migrates various timeout/lifespan usages away from TimeSpan to FiniteDuration/millis. |
| web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala | Updates scheduling and Comet timeout scheduling to match new duration/millis APIs. |
| web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala | Changes LiftRules duration factories/vars to FiniteDuration or explicit millisecond Longs. |
| web/webkit/src/main/scala/net/liftweb/http/LiftMerge.scala | Updates lazy snippet timeout arithmetic to use FiniteDuration.toMillis. |
| web/webkit/src/main/scala/net/liftweb/http/js/yui/YUIArtifacts.scala | Updates JS artifacts fadeOut signature to FiniteDuration. |
| web/webkit/src/main/scala/net/liftweb/http/js/JsCommands.scala | Migrates JS command timing types/serialization to FiniteDuration and toMillis. |
| web/webkit/src/main/scala/net/liftweb/http/js/JSArtifacts.scala | Updates core JSArtifacts timing API to FiniteDuration. |
| web/webkit/src/main/scala/net/liftweb/http/js/jquery/JQueryArtifacts.scala | Adapts JQuery artifacts to updated FiniteDuration JSArtifacts API. |
| web/webkit/src/main/scala/net/liftweb/http/js/jquery/JqJsCmds.scala | Migrates jQuery JS commands from TimeSpan to FiniteDuration and toMillis. |
| web/webkit/src/main/scala/net/liftweb/http/js/extcore/ExtCoreArtifacts.scala | Updates ExtCore artifacts fadeOut signature to FiniteDuration. |
| web/webkit/src/main/scala/net/liftweb/http/CometActor.scala | Updates Comet lifespan type and lifespan timeout checks to use toMillis. |
| web/webkit/src/main/scala/net/liftweb/http/auth/HttpAuthentication.scala | Makes nonce validity an explicit millisecond Long via toMillis. |
| web/webkit/src/main/scala/net/liftweb/builtin/comet/AsyncRenderComet.scala | Updates lifespan signature to Box[FiniteDuration]. |
| core/util/src/test/scala/net/liftweb/util/TimeHelpersSpec.scala | Reworks tests to validate formatDuration and retained time helper functions. |
| core/util/src/test/scala/net/liftweb/util/ScheduleSpec.scala | Updates scheduling tests to pass FiniteDuration delays (10.millis). |
| core/util/src/main/scala/net/liftweb/util/Wiring.scala | Updates dependent notification scheduling to use FiniteDuration. |
| core/util/src/main/scala/net/liftweb/util/TimeHelpers.scala | Removes TimeSpan implementation and adds formatDuration(millis: Long). |
| core/util/src/main/scala/net/liftweb/util/Schedule.scala | Changes scheduler API to accept FiniteDuration and converts to millis for executor scheduling. |
| core/actor/src/main/scala/net/liftweb/actor/LAPinger.scala | Updates documentation to reflect millisecond-based delay parameter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
102
to
104
| * @return a <code>ScheduledFuture</code> which sends the <code>msg</code> to | ||
| * the <code>to<code> Actor after the specified TimeSpan <code>delay</code>. | ||
| * the <code>to<code> Actor after the specified FiniteDuration <code>delay</code>. | ||
| */ |
Comment on lines
111
to
113
| * @return a <code>ScheduledFuture</code> which sends the <code>msg</code> to | ||
| * the <code>to<code> Actor after the specified TimeSpan <code>delay</code>. | ||
| * the <code>to<code> Actor after the specified FiniteDuration <code>delay</code>. | ||
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the Lift framework's time and scheduling utilities to use Scala's standard
FiniteDurationinstead of the customTimeSpantype, removes deprecated and ambiguous time-related code, and simplifies duration formatting. It also updates the relevant tests and documentation to reflect these changes.Key changes include:
Migration from
TimeSpantoFiniteDurationTimeSpantype with Scala'sFiniteDurationin scheduling APIs and internal implementations, including inSchedule,Wiring, and associated tests. This makes the codebase more idiomatic and less error-prone. [1] [2] [3] [4] [5] [6] [7]FiniteDurationinstead ofTimeSpan. [1] [2]Removal of Deprecated and Ambiguous Time Helpers
TimeSpan,TimeSpanBuilder, and related implicit conversions fromTimeHelpers, along with the deprecatedConvertableToDatetrait and its implicits. This eliminates sources of ambiguity and potential bugs. [1] [2]Simplification and Modernization
formatDurationmethod for formatting durations as human-readable strings, replacing the old formatting logic.These changes modernize the codebase, reduce technical debt, and align the framework with standard Scala practices.