Skip to content

chore: clean up sbt clean compile warnings#5201

Open
kunwp1 wants to merge 6 commits into
apache:mainfrom
kunwp1:chore/fix-sbt-warnings
Open

chore: clean up sbt clean compile warnings#5201
kunwp1 wants to merge 6 commits into
apache:mainfrom
kunwp1:chore/fix-sbt-warnings

Conversation

@kunwp1
Copy link
Copy Markdown
Contributor

@kunwp1 kunwp1 commented May 25, 2026

What changes were proposed in this PR?

Fixes the six tractable [warn]/deprecation messages emitted by sbt clean compile on JDK 17, and hardens the build so the cleaned-up Java pattern can't be reintroduced.

File Warning Fix
common/pybuilder/.../BoundaryValidator.scala outer reference in this type test (×2) Move nested CompileTimeContext / RuntimeContext case classes to the companion object; the path-dependent macro Position becomes a Pos type parameter. Call sites in PythonTemplateBuilder.scala switch from validator.X(...) to BoundaryValidator.X(...).
file-service/.../DatasetFileNodeSerializer.java uses deprecated API Swap scala.collection.JavaConverters.seqAsJavaList for scala.jdk.javaapi.CollectionConverters.asJava.
common/workflow-operator/.../TestOperators.scala MySQLSourceOpDesc deprecated (×2) Delete the unused inMemoryMySQLSourceOpDesc helper and its import (no callers; MySQL source dead since 1.1.0-incubating).
amber/.../ExecutionResultService.scala inferred existential type Add import scala.language.existentials.

build.sbt — add ThisBuild / Compile / javacOptions ++= Seq("-Xlint:deprecation", "-Werror") so any future Java caller of a deprecated API (e.g. re-introducing scala.collection.JavaConverters in Java) fails the build rather than emitting an [info] line.

Intentionally out of scope: the JwtAuth object deprecated (×2) warnings in ComputingUnitMaster.scala and TexeraWebApplication.scala. The @Deprecated on amber/web/auth/JwtAuth.scala is a real signal — the migration to common/auth is non-trivial (common/auth doesn't depend on Dropwizard), so the cleanup belongs in a separate PR rather than silencing the warning here. Per review discussion on the JwtAuth thread.

Any related issues, documentation, discussions?

Closes #5200

How was this PR tested?

sbt clean compile on Eclipse Adoptium JDK 17.0.19.

Before — eight warning lines:

[warn] BoundaryValidator.scala:78:20: The outer reference in this type test cannot be checked at run time.
[warn] BoundaryValidator.scala:86:20: The outer reference in this type test cannot be checked at run time.
[info] DatasetFileNodeSerializer.java uses or overrides a deprecated API.
[warn] TestOperators.scala:150:6: class MySQLSourceOpDesc in package mysql is deprecated
[warn] TestOperators.scala:151:41: class MySQLSourceOpDesc in package mysql is deprecated
[warn] ExecutionResultService.scala:441:13: inferred existential type ... should be enabled by making the implicit value scala.language.existentials visible.
[warn] ComputingUnitMaster.scala:166:5: object JwtAuth in package auth is deprecated
[warn] TexeraWebApplication.scala:137:5: object JwtAuth in package auth is deprecated

After — only the two intentionally-deferred JwtAuth warnings remain:

[warn] ComputingUnitMaster.scala:166:5: object JwtAuth in package auth is deprecated
[warn] TexeraWebApplication.scala:137:5: object JwtAuth in package auth is deprecated
[warn] two warnings found
[success] Total time: 36 s

Build-hardening check — temporarily reintroduced JavaConverters.seqAsJavaList in DatasetFileNodeSerializer.java and ran sbt "FileService / compile":

[warn] DatasetFileNodeSerializer.java:56:56: <A>seqAsJavaList(scala.collection.Seq<A>) in scala.collection.JavaConverters has been deprecated
[error] DatasetFileNodeSerializer.java: warnings found and -Werror specified
[error] (FileService / Compile / compileIncremental) javac returned non-zero exit code

Reverted before commit. All 224 main Java sources in the repo compile clean under the new flags.

New unit tests added to keep Jacoco honest about the touched lines (codecov patch-coverage feedback):

  • file-service/.../DatasetFileNodeSerializerSpec.scala — file, recursive directory (covers the swapped asJava call), empty directory.
  • common/pybuilder/.../BoundaryValidatorSpec.scalaRuntimeContext and CompileTimeContext construction, field access, structural equality, copy. These case classes only run during macro expansion in production, so runtime instrumentation never saw them; the spec pins the data-class contract and gives codecov real coverage hits.

Test commands:

sbt "FileService / testOnly org.apache.texera.service.type.serde.DatasetFileNodeSerializerSpec"
sbt "PyBuilder / testOnly org.apache.texera.amber.pybuilder.BoundaryValidatorSpec"

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.7)

@github-actions github-actions Bot added engine common platform Non-amber Scala service paths labels May 25, 2026
@kunwp1 kunwp1 requested a review from bobbai00 May 25, 2026 17:24
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.08%. Comparing base (9b850e2) to head (8042b6e).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5201      +/-   ##
============================================
+ Coverage     48.04%   48.08%   +0.03%     
- Complexity     2346     2348       +2     
============================================
  Files          1042     1042              
  Lines         39973    39952      -21     
  Branches       4251     4250       -1     
============================================
+ Hits          19206    19210       +4     
+ Misses        19626    19604      -22     
+ Partials       1141     1138       -3     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø)
agent-service 33.76% <ø> (ø) Carriedforward from 767219a
amber 50.42% <ø> (+0.09%) ⬆️ Carriedforward from 767219a
computing-unit-managing-service 0.00% <ø> (ø)
config-service 0.00% <ø> (ø)
file-service 32.27% <ø> (+0.08%) ⬆️ Carriedforward from 767219a
frontend 40.02% <ø> (ø) Carriedforward from 767219a
python 90.50% <ø> (ø) Carriedforward from 767219a
workflow-compiling-service 56.81% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kunwp1 kunwp1 force-pushed the chore/fix-sbt-warnings branch 2 times, most recently from 43ae460 to dab49c1 Compare May 25, 2026 17:41
@Yicong-Huang
Copy link
Copy Markdown
Contributor

Could you please also add some tests? just to verify those changes have no behavior changes.

Comment thread amber/src/main/scala/org/apache/texera/web/auth/JwtAuth.scala Outdated
aggOp
}

def inMemoryMySQLSourceOpDesc(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MySQL exec implementation was disabled due to license issue. We can remove this (used for test) for now. @bobbai00 whats our plan to add mysql back?

Fixes the eight Scala/Java compiler warnings on JDK 17: lift the nested
BoundaryValidator case classes to its companion object, switch the
DatasetFileNodeSerializer to scala.jdk.javaapi.CollectionConverters,
delete the unused inMemoryMySQLSourceOpDesc test helper, add the
scala.language.existentials import in ExecutionResultService, and drop
the aspirational @deprecated marker on the JwtAuth wrapper (no
replacement exists in common/auth yet; TODO retained).

Closes apache#5200
@kunwp1 kunwp1 force-pushed the chore/fix-sbt-warnings branch from dab49c1 to 74f5f1b Compare May 25, 2026 22:31
kunwp1 added 2 commits May 25, 2026 15:41
Restores the @deprecated annotation on amber/web/auth/JwtAuth. The
TODO migration to common/auth is real but non-trivial (common/auth
doesn't depend on Dropwizard), so the warning is the standard signal
to readers and forks; cleaning it up belongs in a separate PR.

The two call-site warnings in ComputingUnitMaster.scala and
TexeraWebApplication.scala are accepted as intentional.
Adds -Xlint:deprecation -Werror to ThisBuild / Compile / javacOptions
so a deprecated-API call in any Java source becomes a hard build
error, preventing reintroduction of patterns like
scala.collection.JavaConverters.seqAsJavaList in Java callers (the
modern entry point is scala.jdk.javaapi.CollectionConverters).

Verified by temporarily restoring the deprecated call in
DatasetFileNodeSerializer.java; FileService / compile failed with
"warnings found and -Werror specified". All 224 main Java sources in
the repo compile clean under the new flags.
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label May 25, 2026
kunwp1 and others added 3 commits May 25, 2026 15:59
The companion-object case classes generated a large pile of
equals/hashCode/copy/Product/unapply bytecode that runs only inside
the macro at compile time, so Jacoco never recorded hits and codecov
reported BoundaryValidator.scala at ~75% patch coverage with two
partials it was structurally hard to close.

Convert the two carriers to plain final classes with companion apply
factories. Call sites in PythonTemplateBuilder already use
BoundaryValidator.X(...) syntax, which now resolves to the new
apply methods, so no caller change is needed.

Simplify BoundaryValidatorSpec to match the slimmer surface
(construction + field access), and add one assertion that touches
the outer object directly so its static initializer is recorded.
Result: every executable line in the new code is HIT, including
line 24 (the outer object header).

Verified locally with `sbt PyBuilder/jacoco` — every line in the
24-68 range reports HIT with 0 missed instructions; 127 tests pass.
Signed-off-by: Kunwoo (Chris) <143021053+kunwp1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common dependencies Pull requests that update a dependency file engine platform Non-amber Scala service paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up sbt clean compile warnings

3 participants