Skip to content

Commit 1ff2aa2

Browse files
Mark Pollackmarkpollack
authored andcommitted
Coverage gate: JDK 21 floors for modules that cover more on JDK 21
The Jetty launcher covers line 85.8%, branch 86.7% on JDK 21, where its virtual-thread pool runs, but 76.4% and 70.0% on JDK 17; one floor for both let the JDK 21 build lose 16 points of branches unnoticed. A module may now declare jacoco.jdk21.minimum.line and .branch, which the coverage-jdk21 profile (JDK 21+) makes the gate check; without them JDK 21 checks the module's floors as before. The launcher gets 0.83 line, 0.84 branch on JDK 21.
1 parent 2f89947 commit 1ff2aa2

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,9 @@ that authenticates in front. Browser requests whose `Origin` is not a loopback o
512512
`./mvnw verify` writes a JaCoCo coverage report for each module to
513513
`<module>/target/site/jacoco/index.html`, and fails if a module's line or branch coverage drops
514514
below the floor declared in its `pom.xml` (measured coverage less 2 points). Each module counts
515-
only its own classes, covered by its own tests. The classes that choose between virtual threads
515+
only its own classes, covered by its own tests. A module whose JDK 21 build covers more (its
516+
virtual-thread code runs only there) also declares JDK 21 floors, which a JDK 21 build checks
517+
instead. The classes that choose between virtual threads
516518
(JDK 21 and later) and platform threads (JDK 17) must have every branch covered on whichever JDK
517519
builds, so CI's JDK 17 and JDK 21 builds each prove both choices. When running a subset of tests
518520
under `verify` (`-Dtest=...`), add `-Djacoco.skip` to skip the gate.

‎acp-streamable-http-jetty/pom.xml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
<properties>
2020
<!-- Coverage floors: the launcher alone (the servlet host it runs is measured in
21-
acp-http-servlet). Measured line 85.8%, branch 86.7% on JDK 21, and line 76%, branch
22-
70% on JDK 17, where the virtual-thread pool paths cannot run; the JDK 17 figures less
23-
2 points (parent pom, JaCoCo) -->
21+
acp-http-servlet). Measured line 76.4%, branch 70.0% on JDK 17, where the
22+
virtual-thread pool paths cannot run, and line 85.8%, branch 86.7% on JDK 21; each
23+
JDK's figures less 2 points (parent pom, JaCoCo) -->
2424
<jacoco.minimum.line>0.74</jacoco.minimum.line>
2525
<jacoco.minimum.branch>0.68</jacoco.minimum.branch>
26+
<jacoco.jdk21.minimum.line>0.83</jacoco.jdk21.minimum.line>
27+
<jacoco.jdk21.minimum.branch>0.84</jacoco.jdk21.minimum.branch>
2628
<!-- JaCoCo's prepare-agent sets argLine; empty when JaCoCo is skipped. -->
2729
<argLine/>
2830
</properties>

‎pom.xml‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@
119119
<!-- Coverage floors; each module overrides them with its own (see the JaCoCo plugin) -->
120120
<jacoco.minimum.line>1.00</jacoco.minimum.line>
121121
<jacoco.minimum.branch>1.00</jacoco.minimum.branch>
122+
<!-- A module whose JDK 21 build runs code JDK 17 cannot (virtual threads) declares
123+
higher floors for it; otherwise JDK 21 checks the same floors. -->
124+
<jacoco.jdk21.minimum.line>${jacoco.minimum.line}</jacoco.jdk21.minimum.line>
125+
<jacoco.jdk21.minimum.branch>${jacoco.minimum.branch}</jacoco.jdk21.minimum.branch>
126+
<!-- The floors the gate checks on this JDK (the coverage-jdk21 profile switches them) -->
127+
<jacoco.gate.line>${jacoco.minimum.line}</jacoco.gate.line>
128+
<jacoco.gate.branch>${jacoco.minimum.branch}</jacoco.gate.branch>
122129
<owasp.version>13.0.0</owasp.version>
123130
<cyclonedx-maven-plugin.version>2.9.3</cyclonedx-maven-plugin.version>
124131
<maven-pmd-plugin.version>3.28.0</maven-pmd-plugin.version>
@@ -531,7 +538,12 @@
531538
(integration-testing/) is outside the Maven build and is not counted.
532539
533540
The gate (check, in verify) fails when a module's LINE or BRANCH covered ratio
534-
falls below its floor. Every module declares jacoco.minimum.line and
541+
falls below its floor. CI builds on JDK 17 and on JDK 21, and a module may cover
542+
more on JDK 21, where its virtual-thread code runs: such a module also declares
543+
jacoco.jdk21.minimum.line and jacoco.jdk21.minimum.branch, which the JDK 21
544+
build checks instead (the coverage-jdk21 profile); without them JDK 21 checks
545+
the same floors. Measure a floor on both JDKs: the JDK 17 one from the JDK 17
546+
build, the JDK 21 one from the JDK 21 build, and a shared floor from the lower. Every module declares jacoco.minimum.line and
535547
jacoco.minimum.branch; the default below is full coverage, so a new module
536548
fails until it declares measured floors. A floor is the coverage measured from a clean verify less a margin of
537549
2 points, rounded down to a whole percent: enough for the run-to-run variation
@@ -586,12 +598,12 @@
586598
<limit>
587599
<counter>LINE</counter>
588600
<value>COVEREDRATIO</value>
589-
<minimum>${jacoco.minimum.line}</minimum>
601+
<minimum>${jacoco.gate.line}</minimum>
590602
</limit>
591603
<limit>
592604
<counter>BRANCH</counter>
593605
<value>COVEREDRATIO</value>
594-
<minimum>${jacoco.minimum.branch}</minimum>
606+
<minimum>${jacoco.gate.branch}</minimum>
595607
</limit>
596608
</limits>
597609
</rule>
@@ -622,6 +634,17 @@
622634
</build>
623635

624636
<profiles>
637+
<!-- The coverage gate's JDK 21 floors (see the JaCoCo plugin). -->
638+
<profile>
639+
<id>coverage-jdk21</id>
640+
<activation>
641+
<jdk>[21,)</jdk>
642+
</activation>
643+
<properties>
644+
<jacoco.gate.line>${jacoco.jdk21.minimum.line}</jacoco.gate.line>
645+
<jacoco.gate.branch>${jacoco.jdk21.minimum.branch}</jacoco.gate.branch>
646+
</properties>
647+
</profile>
625648
<!-- Error Prone: Error Prone's own bug checks and NullAway, at ERROR, on main sources.
626649
Error Prone 2.50 runs only on JDK 21+, while the SDK targets Java 17 and its
627650
release build runs on JDK 17, so the profile activates by JDK: every build on

0 commit comments

Comments
 (0)