Background
Two utility modules in engine/common currently lack a dedicated unit-spec:
| Source class |
Purpose |
FutureBijection |
Implicit-class extensions converting between Twitter Future and Scala Future (both success and failure paths) — used wherever the engine bridges twitter-util-based RPC with scala-future-based code |
ElidableStatement |
Tiny logging helper that wraps by-name blocks in scala.annotation.elidable so they compile away below the configured level |
Behavior to pin
FutureBijection
| Surface |
Contract |
TwitterFuture.value.asScala |
resolves to the same value |
TwitterFuture.exception.asScala |
resolves with the same Throwable (preserves exception type + message) |
ScalaFuture.successful.asTwitter |
resolves to the same value |
ScalaFuture.failed.asTwitter |
resolves with the same Throwable |
| both directions |
preserve null-vs-value semantics on the value path |
| Twitter → Scala → Twitter and Scala → Twitter → Scala |
round-trip values and exceptions |
ElidableStatement
The texera build sets -Xelide-below WARNING (amber/build.sbt). Every ElidableStatement helper is annotated with an elide level strictly below WARNING (FINEST / FINER / FINE / INFO), so the Scala compiler replaces every CALL to these helpers with a () Unit value at compile time. The spec pins this silent-in-production contract:
| Surface |
Contract |
info / fine / finer / finest (block executes side effect) |
the side effect MUST NOT fire (block is elided) |
| same methods (block throws) |
the exception MUST NOT propagate (block is elided) |
| 1000 successive elided calls |
the side-effect counter remains at 0 |
| return type |
Unit (compile-time enforced) |
| parameter shape |
accepts a => Unit by-name block (compile-time enforced) |
A regression that bumped a method's elide level above WARNING, removed the @elidable annotation, or relaxed -Xelide-below in the build would re-enable side effects in production — and this spec would catch it.
Scope
- New spec files (one per source class per the spec-filename convention):
FutureBijectionSpec.scala
ElidableStatementSpec.scala
- No production-code changes.
FutureBijection spec uses Await.result / TwitterAwait.result with a short timeout to drive the underlying futures to completion.
Background
Two utility modules in
engine/commoncurrently lack a dedicated unit-spec:FutureBijectionFutureand ScalaFuture(both success and failure paths) — used wherever the engine bridges twitter-util-based RPC with scala-future-based codeElidableStatementscala.annotation.elidableso they compile away below the configured levelBehavior to pin
FutureBijectionTwitterFuture.value.asScalaTwitterFuture.exception.asScalaThrowable(preserves exception type + message)ScalaFuture.successful.asTwitterScalaFuture.failed.asTwitterThrowableElidableStatementThe texera build sets
-Xelide-below WARNING(amber/build.sbt). EveryElidableStatementhelper is annotated with an elide level strictly below WARNING (FINEST / FINER / FINE / INFO), so the Scala compiler replaces every CALL to these helpers with a()Unit value at compile time. The spec pins this silent-in-production contract:info/fine/finer/finest(block executes side effect)Unit(compile-time enforced)=> Unitby-name block (compile-time enforced)A regression that bumped a method's elide level above WARNING, removed the
@elidableannotation, or relaxed-Xelide-belowin the build would re-enable side effects in production — and this spec would catch it.Scope
FutureBijectionSpec.scalaElidableStatementSpec.scalaFutureBijectionspec usesAwait.result/TwitterAwait.resultwith a short timeout to drive the underlying futures to completion.