Compare commits
25
Commits
2996628ff1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a95f042051 | ||
|
|
2a8219a6ee | ||
|
|
24dc4ba3ff | ||
|
|
658bc52e2b | ||
|
|
cbcfb05e35 | ||
|
|
5f85ec8d53 | ||
|
|
da700a564f | ||
|
|
c9a2b766bb | ||
|
|
fe3fc689a6 | ||
|
|
ae696369ba | ||
|
|
1497fba911 | ||
|
|
6a36e84858 | ||
|
|
8da3374155 | ||
|
|
dc13293046 | ||
|
|
51913ad9d4 | ||
|
|
3a30194459 | ||
|
|
9b1da079c6 | ||
|
|
bded24d929 | ||
|
|
85074ed51a | ||
|
|
fd0cf9b527 | ||
|
|
99a8a0df42 | ||
|
|
93c709c34d | ||
|
|
809272f7dc | ||
|
|
8252cba4c5 | ||
|
|
917d39fb65 |
@@ -9,6 +9,19 @@ files.
|
||||
|
||||
| Directory | Article | What it demonstrates |
|
||||
|---|---|---|
|
||||
| [`boot-versions/`](boot-versions) | [Spring Boot Versions: Release Dates, End of Support (4.0 Ends Dec 31, 2026) and Java Baselines](https://ankurm.com/spring-boot-versions/) | versions and release dates read from Maven Central and support dates from `api.spring.io`, one app built against 2.7.18 to 4.2.0 and booted on JDK 8 to 27, 3.5+ failing below Java 17 while a `--release 11` build still says `BUILD SUCCESS`, 2.7.18 failing to scan Java 25 classes, `layertools` gone after 4.0, jOOQ managed by 4.1+ needing Java 21, and a configuration-property diff from 4.0.10 to 4.2.0 |
|
||||
| [`openfeature/`](openfeature) | [Feature Flags in Spring Boot with OpenFeature and flagd: Targeting, Gradual Rollout and Failure Modes](https://ankurm.com/spring-boot-feature-flags-openfeature-flagd/) | the OpenFeature Java SDK 1.23.0 and flagd 0.19.0 behind Spring Boot 4.2.0: five flag types and their reasons, targeting by tier and e-mail domain, a 10% rollout measured on 1000 users (100 on, and 0 flipped off when widened to 50%), a flag file edited under a connected client, flagd absent at start (`PROVIDER_NOT_READY`) and killed mid-run (targeted flags fall back to the code default while a static flag keeps answering `CACHED`), unknown keys and type mismatches, `InMemoryProvider` tests of both states and the in-process `FILE` resolver giving the same 100 of 1000 |
|
||||
| [`resttemplate-to-restclient/`](resttemplate-to-restclient) | [RestTemplate Is Deprecated in Spring Framework 7.1: Migrate to RestClient (and TestRestTemplate to RestTestClient)](https://ankurm.com/resttemplate-to-restclient-migration-guide/) | the `[removal]` warnings on 4.2.0 vs none on 4.1.3, every `RestTemplate` method next to its `RestClient` call on one real server, `exchange()` that stops throwing, the `RestClient.create(restTemplate)` bridge that changes URI encoding, PATCH and `User-Agent` of each default stack, an interceptor that eats the body, `TestRestTemplate` vs `RestTestClient`, and the OpenRewrite recipe's output run for real |
|
||||
| [`email/`](email) | [Sending Emails in Spring Boot 4: SMTP, HTML Templates, Attachments and Testing](https://ankurm.com/sending-emails-in-spring-boot-3-a-complete-guide/) | the MIME tree of six message shapes (`multipart/mixed` > `related` > `alternative`, and `addInline` before `setText` putting the image first), Thymeleaf HTML and TEXT templates (`[[...]]` still HTML-escapes in TEXT mode), Devanagari subjects as encoded-words and a wrong `defaultEncoding` turning them into `?`, one `send` per message (5 connections) vs the varargs `send` (1), `@Async` returning in milliseconds and a `void @Async` failure that never reaches the caller, a server that never greets blocking forever until `mail.smtp.timeout` is set (`connectiontimeout` does not help), `starttls.enable` authenticating in plain text while `starttls.required` refuses, an email still sent when the transaction rolls back unless it waits for `AFTER_COMMIT`, all against GreenMail on Spring Boot 4.1.2 |
|
||||
| [`log4j2-levels/`](log4j2-levels) | [Log4j2 Logging Levels Explained: Configuration, Custom Levels and Changing Levels at Runtime](https://ankurm.com/log4j2-logging-levels-complete-guide/) | the threshold rule printed as a matrix, a level inherited from the nearest configured ancestor, a logger with its own appender and default additivity printing every line twice, custom `DIAG`/`PERF` levels between the standard ones, `/actuator/loggers` rejecting a custom level and a `null` reset landing on the root's level instead of the XML's, `logging.level.*` beating the XML and a custom level in that property stopping the app at startup, argument `toString()` counts for six call shapes, and Logback plus Log4j2 on one classpath silently handing everything to Logback |
|
||||
| [`idempotency/`](idempotency) | [Idempotency Keys for POST APIs in Spring Boot (Stripe-Style) with Redis and Postgres](https://ankurm.com/idempotency-keys-spring-boot-redis-postgres/) | one servlet filter and two interchangeable stores: a retried POST after a client timeout creating two payments without a key and one with; 400 / 422 / 409 and replay with `Idempotent-Replayed`; ten simultaneous duplicates (nine `409` on Redis, nine replays on Postgres because the second `INSERT` waits on the first's uncommitted row); a crash after the payment commits leaving Redis with a stuck lock and then a duplicate payment, and Postgres with neither; a handler slower than the Redis lock finishing with nothing stored; the legacy `Asia/Calcutta` zone id that PostgreSQL 16 refuses at connect time |
|
||||
| [`http-service-clients/`](http-service-clients) | [Spring Boot 4 HTTP Service Clients: @HttpExchange Interfaces with RestClient (Complete Guide)](https://ankurm.com/spring-boot-4-http-service-clients/) | `@HttpExchange` interfaces registered with `@ImportHttpServices` and configured under `spring.http.serviceclient.<group>.*` (the keys the first version of the post gave are silently ignored), run against a local stub upstream: `defaultStatusHandler` with ProblemDetail decoding, `NotFoundRestClientAdapterDecorator` for `Optional` on a 404, Framework 7 `@Retryable` on the interface vs `RetryTemplate` vs an interceptor vs Resilience4j (call counts side by side, and a retried POST created twice), bearer, API-key and OAuth2 client-credentials auth (`@ClientRegistrationId` ignored without its group configurer), `MockRestServiceServer`, and the `@RestClientTest` slice where a group client is not bound to the mock |
|
||||
| [`pdf-invoice/`](pdf-invoice) | [Generate PDF Invoices in Spring Boot: OpenPDF vs iText vs Flying Saucer (HTML to PDF)](https://ankurm.com/spring-boot-generate-pdf-invoice-openpdf-itext-flying-saucer/) | one invoice rendered by OpenPDF 3.0.5, iText Core 9.8.0 (AGPL 3 or commercial) and Flying Saucer 10.7.0 from a Thymeleaf template, with embedded Noto Sans Devanagari: none of the three shapes Marathi/Hindi conjuncts by default (checked by rendering to PNG against a libraqm reference), OpenPDF's `GlyphLayoutManager` does but breaks text extraction until `ActualText` is on, OpenPDF's static `LayoutProcessor` is JVM-global and breaks other writers, Apache FOP on the classpath did not help, streamed vs buffered failure (`200` + curl exit 18 vs `500`), font subsetting, indicative per-invoice timings |
|
||||
| [`filter-interceptor-aop/`](filter-interceptor-aop) | [Filter vs HandlerInterceptor vs AOP in Spring Boot 4: Which Runs When](https://ankurm.com/spring-boot-filter-vs-handlerinterceptor-vs-aop-which-runs-when/) | the real order of a servlet filter, a `HandlerInterceptor` and an `@Aspect` printed from a running Tomcat and from MockMvc, the callbacks that still fire (and the ones that do not) after an exception, a 404, a `preHandle` that returns false and an async request, `afterCompletion` seeing `ex=null` after `@ControllerAdvice`, a header added in `postHandle` silently lost, a request body read twice, `ContentCachingResponseWrapper` returning an empty 200, Spring Security 7's chain sitting at order -100, a filter bean running twice, the Framework 7 path-matching removals read with `javap`, and the three self-invocation-style cases an aspect never sees |
|
||||
| [`excel-export/`](excel-export) | [Export Excel and CSV from Spring Boot: Streaming 1 Million Rows with Apache POI SXSSF](https://ankurm.com/spring-boot-export-excel-csv-streaming-poi-sxssf/) | XSSF vs SXSSF under a fixed 512 MB heap (XSSF out of memory between 50,000 and 100,000 rows and at 1,000,000 rows even with 3 GB), 1,000,000 rows streamed with `StreamingResponseBody` under a 64 MB heap, sheet rolling at 1,048,576 rows, `compressTempFiles` cutting the spill from 475 MB to 56 MB, OpenCSV swallowing write errors, and an SXSSF file LibreOffice will not open |
|
||||
| [`thymeleaf-htmx/`](thymeleaf-htmx) | [Spring Boot 4 + Thymeleaf + htmx: Server-Side CRUD UI in 2026](https://ankurm.com/spring-boot-thymeleaf-htmx-crud-ui/) | one URL answering as full page or fragment on `HX-Request`, a Thymeleaf layout, 422 validation re-render, pagination, inline edit and delete, 10 MockMvc tests plus a headless-Chromium check that observed htmx 2 ignoring a 204 and (without a config tag) a 422 |
|
||||
| [`rate-limit/`](rate-limit) | [Rate Limiting Spring Boot APIs with Bucket4j and Redis: Per-User, Per-Key and Global Limits](https://ankurm.com/spring-boot-rate-limiting-bucket4j-redis/) | per-user, per-API-key and global token buckets in a servlet filter on Bucket4j 8.21 (`bucket4j_jdk17-*`), `429` with `Retry-After` and `X-RateLimit-*` headers, two application instances sharing one Redis bucket and 200 concurrent requests letting exactly 20 through, a limit raised in `application.yml` that does not change buckets already stored in Redis until a config version is bumped, a client clock 30 s ahead handing out tokens another instance already spent, and fail-open versus fail-closed when Redis dies |
|
||||
| [`sbom/`](sbom) | [Spring Boot SBOM in Practice: the tools jar-mode sbom Command, CycloneDX and Dependency Scanning](https://ankurm.com/spring-boot-sbom-tools-jarmode-cyclonedx-dependency-scanning/) | the 4.2.0-RC1 `java -Djarmode=tools -jar app.jar sbom` command (absent in 4.1.2), the CycloneDX document the build puts in the jar, `/actuator/sbom`, an SBOM that lists 8 starters not in the jar and misses the jar mode's own library, a licence rule that wrongly flags dual-licensed logback, and an OSV scan that finds Log4Shell in a deliberately old build |
|
||||
| [`hexagonal/`](hexagonal) | [Hexagonal Architecture (Ports and Adapters) in Spring Boot 4](https://ankurm.com/hexagonal-architecture-ports-and-adapters-spring-boot-4/) | a 4-module Maven reactor that makes "the core has no Spring dependency" something `mvn dependency:tree` proves rather than a naming convention, testing the core with zero Spring context, and a Spring Boot 4 test-slice-artifact split (`@DataJpaTest`, `@WebMvcTest`, `TestRestTemplate`) hit and fixed along the way |
|
||||
| [`actuator-in-production/`](actuator-in-production) | [Spring Boot Actuator in Production](https://ankurm.com/spring-boot-actuator-production-endpoints-security-health-indicators/) | endpoint exposure defaults, securing Actuator, custom health indicators and how they hang |
|
||||
| [`spring-boot-startup-time/`](spring-boot-startup-time) | [Why Your Spring Boot App Takes 8 Seconds to Start](spring-boot-startup-time/post/post.md) | `BufferingApplicationStartup`, JFR startup events, self time vs total time, the classpath-scan tax, the JDK 25 AOT cache |
|
||||
@@ -45,6 +58,14 @@ files.
|
||||
| [`file-transfer/`](file-transfer) | [File Upload and Download in Spring Boot 4: Multipart, Streaming and S3 Presigned URLs](https://ankurm.com/file-upload-download-spring-boot-4-multipart-streaming-s3-presigned-urls/) | multipart limits enforced by Tomcat (and ignored by `MockMvc`), the client-controlled filename, `Range` downloads, a 200 MB download and 150 MB upload under `-Xmx64m`, and S3 presigned URLs checked against a local SigV4 verifier (not a real S3) |
|
||||
| [`project-structure/`](project-structure) | [Spring Boot Project Structure: Package-by-Layer vs Package-by-Feature](https://ankurm.com/spring-boot-project-structure/) | the same application written package-by-layer and package-by-feature with one HTTP API, the real source trees, 9 of 9 types public by layer vs 3 of 15 by feature, and the `javac` error that makes a feature boundary a compiler rule instead of a convention |
|
||||
| [`crud-mysql/`](crud-mysql) | [Spring Boot CRUD REST API with MySQL and Spring Data JPA](https://ankurm.com/spring-boot-crud-rest-api-mysql/) | a complete book API on a real MySQL 8.4.6 server with Flyway owning the schema and Hibernate set to `validate`, `ProblemDetail` errors with per-field validation messages, a duplicate ISBN caught by the database's unique key and mapped to `409` on create and on update, MySQL's own `Duplicate entry` message, and the SQL behind every request |
|
||||
| [`boot42-rc1-checklist/`](boot42-rc1-checklist) | [Spring Framework 7.1 and Spring Boot 4.2: What's Coming and How to Prepare](https://ankurm.com/spring-boot-4-2-spring-framework-7-1-upgrade-checklist/) | **superseded by [`boot42-upgrade/`](boot42-upgrade); kept because older posts link to it.** Each 4.2 milestone change run on 4.2.0-RC1 and on 4.1.2: `@DefaultValue` placeholders resolved, five new Kafka admin keys that 4.1.2 silently ignores, embedded LDAP SSL failing without a bundle, the properties migrator's real report (and the removed key it misses), and the `RestTemplate` removal warnings from the compiler |
|
||||
| [`boot42-upgrade/`](boot42-upgrade) | [Spring Boot 4.2 GA: What's New, What's Deprecated and the 4.1 to 4.2 Upgrade Checklist](https://ankurm.com/spring-boot-4-2-spring-framework-7-1-upgrade-checklist/) | the 4.2.0 GA re-run of the RC1 checklist against 4.1.3: `@DefaultValue` placeholders, Kafka admin keys that 4.1.3 silently ignores, embedded LDAP SSL without a bundle, SSL-bundle `options` rejected by the LDAP client, the migrator's real report and its new `spring.properties.migrator.fail` switch, compiler `[removal]` warnings for `RestTemplate`, `TestRestTemplate` and the Pulsar classes, `open-telemetry` convention now starting, plus defaults, buildpack builder constants and BOM versions read straight from the 4.1.3 and 4.2.0 artifacts |
|
||||
| [`boot42-otel/`](boot42-otel) | [Spring Boot 4.2 OpenTelemetry: Semantic Conventions, Shared OTLP Settings and MDC Keys](https://ankurm.com/spring-boot-4-2-opentelemetry-semantic-conventions-shared-otlp-mdc/) | one request measured under each `management.observations.conventions` value (the documented `open-telemetry` fails to start on RC1, `opentelemetry` works), meter, span and Prometheus names before and after, `management.opentelemetry.otlp.*` verified against a local OTLP receiver (paths, merged headers, gzip, per-signal overrides), custom MDC keys, and the LongTaskTimer that is no longer on by default |
|
||||
| [`boot4-migration/`](boot4-migration) | [Spring Boot 3 to 4 Migration Guide (Updated for 4.1 and 4.2)](https://ankurm.com/spring-boot-3-to-4-migration-guide/) | one Boot 3.5.16 service migrated to 4.1.2 with the real failures captured at each step: 12 javac errors from a version bump, a start-up failure from a missing `spring-boot-starter-restclient`, Flyway silently not running without `spring-boot-starter-flyway`, removed `logging.file.*` keys silently ignored, Jackson 3 sorting bean properties, liveness/readiness groups appearing, and a `@Mock` field that is `null` without `MockitoExtension` |
|
||||
| [`startup-runners/`](startup-runners) | [CommandLineRunner vs ApplicationRunner vs ApplicationReadyEvent in Spring Boot 4](https://ankurm.com/commandlinerunner-vs-applicationrunner-vs-applicationreadyevent-spring-boot-4/) | the real order of every startup hook printed from a running app, one shared sort for both runner types with arbitrary ties, runner failure vs `ApplicationReadyEvent` listener failure (exit codes, `ApplicationFailedEvent`), a blocking runner holding readiness at 503, `SmartLifecycle` phases, and which hooks `@SpringBootTest` and `@WebMvcTest` run |
|
||||
| [`mapstruct/`](mapstruct) | [MapStruct with Spring Boot 4 and Java Records: DTO Mapping Done Right](https://ankurm.com/mapstruct-spring-boot-4-java-records-dto-mapping/) | records as source and target, nested and collection mapping, null strategies, `@AfterMapping` and `@DecoratedWith`, real compile-time error text for broken mappers, three ways to test a mapper, and an indicative comparison with hand-written code and Dozer |
|
||||
| [`secrets/`](secrets) | [Secrets in Spring Boot: Vault vs AWS Secrets Manager vs Kubernetes Secrets vs Jasypt](https://ankurm.com/spring-boot-secrets-management-vault-aws-kubernetes-jasypt/) | `spring.config.import` against a real Vault 2.2.1 (Spring Cloud Vault 5.0.3 on Boot 4.1.2): a missing path, a wrong token and an unreachable Vault all start the app with `db.password` unset unless `spring.cloud.vault.fail-fast=true` (and a missing path even then); a rotation in Vault invisible until `ContextRefresher.refresh()`, which updates the Environment and a `@RefreshScope` bean but not a record-bound `@ConfigurationProperties`; a least-privilege token; AWS Secrets Manager (Spring Cloud AWS 4.2.1, run against the moto emulator, not AWS) where a missing secret fails startup but `optional:` hides it and the 1 s polling reload never fired; Kubernetes Secrets as a kubelet-layout config tree that keeps its old value after the volume swap until a refresh; Jasypt 4.0.4 `ENC(...)` decrypted by anyone holding the ciphertext and the key; actuator `show-values=ALWAYS`; secrets in the jar, in `ps` and in `/proc/<pid>/environ`; and `@DynamicPropertySource` arriving after the Vault import |
|
||||
| [`otel-agent-vs-micrometer/`](otel-agent-vs-micrometer) | [OpenTelemetry Java Agent vs Micrometer Tracing in Spring Boot 4: Zero-Code vs In-Code](https://ankurm.com/opentelemetry-java-agent-vs-micrometer-tracing-spring-boot-4/) | one orders app built twice (no tracing dependency + `-javaagent` 2.34.0, and `spring-boot-starter-opentelemetry`) exporting OTLP to a decoding receiver: span trees, attribute keys and metric names side by side, `management.observations.conventions=opentelemetry` on 4.2.0, spans lost across a plain thread pool, JDBC spans via the agent vs a third-party library, both at once, startup/CPU cost |
|
||||
|
||||
`core-di`, `core-beans`, `custom-starter`, `core-events`, `multi-datasource`, `i18n`, `aot-cache`, `kotlin`, `testing-no-containers`, `rest-test-client` and `hexagonal` are the exception: they have **no `docs/NN-topic.md` chapter folder**. Their deeper material lives in
|
||||
collapsible sections inside the articles themselves. Where their captured output sits is not
|
||||
@@ -62,8 +83,8 @@ categories.
|
||||
|
||||
## Running any of them
|
||||
|
||||
Each project needs a JDK 25 and Maven 3.9. `redis` also needs `redis-server` and `redis-cli` on the
|
||||
`PATH`. `docker-images` and `observability` also need
|
||||
Each project needs a JDK 25 and Maven 3.9. `redis` and `rate-limit` also need `redis-server` and `redis-cli` on the
|
||||
`PATH`. `docker-images`, `observability` and `secrets` also need
|
||||
Docker, and `kubernetes-deployment` Docker plus a Kubernetes cluster; their READMEs list the rest:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# boot-versions
|
||||
|
||||
Companion module for the ankurm.com article [Spring Boot Versions: Release Dates, End of Support (4.0 Ends Dec 31, 2026) and Java Baselines](https://ankurm.com/spring-boot-versions/). Figures were captured on **3 December 2026**, when the latest releases were 4.2.0, 4.1.3 and 4.0.10.
|
||||
|
||||
| Path | What it is |
|
||||
|---|---|
|
||||
| `src/main/java/.../VersionReport` | prints versions and release dates from Maven Central, support dates from `api.spring.io`, Java baselines (docs page and the class file version in the published jar), BOM versions, the upcoming-release calendar and a configuration-property diff 4.0.10 to 4.2.0 |
|
||||
| `src/test/.../SupportTest` | pins the support dates to a saved copy of the API answer; runs offline once dependencies are cached |
|
||||
| `probe/` | one small application built against 2.7.18, 3.5.16, 4.0.10, 4.1.3 and 4.2.0 (`-Dboot.version=`) |
|
||||
| `scripts/report.sh` | outputs 01-04 and 07 (set `TODAY=yyyy-MM-dd` to compute day counts for another date) |
|
||||
| `scripts/matrix.sh` | outputs 05-06: each Boot line on JDK 8, 11, 17, 21, 25 and 27, plus the compile-target limits |
|
||||
| `scripts/upgrade-and-check.sh` | outputs 08-10: reading your version, `layertools` on 4.0 vs 4.1/4.2, the jOOQ Java floor |
|
||||
| `output/` | every transcript quoted in the article, and the raw API answer (`api-generations.json`) |
|
||||
|
||||
Run (JDK 25 to build; `matrix.sh` also needs the other JDKs):
|
||||
|
||||
```bash
|
||||
mvn test
|
||||
JDK8=... JDK11=... JDK17=... JDK21=... JDK25=... JDK27=... ./scripts/run-all.sh
|
||||
```
|
||||
|
||||
Reruns will differ as new patches ship and days pass. Maven Central may answer `429` when asked too often; the tool waits and retries.
|
||||
|
||||
A probe app that boots on a newer JDK is not a statement of support: only the documented Java range is.
|
||||
|
||||
There is deliberately no `docs/` folder: the explanations live in the article.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Maven Central, org.springframework.boot:spring-boot-dependencies, read on 2026-12-03
|
||||
latest GA overall: 4.2.0
|
||||
line x.y.0 date latest patch patch date patches
|
||||
2.0 2018-03-01 2.0.9.RELEASE 2019-04-03 10
|
||||
2.1 2018-10-30 2.1.18.RELEASE 2020-10-29 19
|
||||
2.2 2019-10-16 2.2.13.RELEASE 2021-01-14 14
|
||||
2.3 2020-05-15 2.3.12.RELEASE 2021-06-10 13
|
||||
2.4 2020-11-12 2.4.13 2021-11-18 14
|
||||
2.5 2021-05-20 2.5.15 2023-05-18 16
|
||||
2.6 2021-11-19 2.6.15 2023-05-18 16
|
||||
2.7 2022-05-19 2.7.18 2023-11-23 19
|
||||
3.0 2022-11-24 3.0.13 2023-11-23 14
|
||||
3.1 2023-05-18 3.1.12 2024-05-23 13
|
||||
3.2 2023-11-23 3.2.12 2024-11-21 13
|
||||
3.3 2024-05-23 3.3.13 2025-06-19 14
|
||||
3.4 2024-11-21 3.4.13 2025-12-18 14
|
||||
3.5 2025-05-22 3.5.16 2026-06-25 17
|
||||
4.0 2025-11-20 4.0.10 2026-11-19 11
|
||||
4.1 2026-06-10 4.1.3 2026-11-19 4
|
||||
4.2 2026-11-19 4.2.0 2026-11-19 1
|
||||
@@ -0,0 +1,19 @@
|
||||
# https://api.spring.io/projects/spring-boot/generations, status computed for 2026-12-03
|
||||
line listed start OSS ends commercial ends kind status OSS days left
|
||||
2.0.x 2018-03-31 2019-03-31 2020-06-30 default ENDED -
|
||||
2.1.x 2018-10-31 2019-10-31 2021-01-31 default ENDED -
|
||||
2.2.x 2019-10-31 2020-10-31 2022-01-31 default ENDED -
|
||||
2.3.x 2020-05-31 2021-05-31 2022-08-31 default ENDED -
|
||||
2.4.x 2020-11-30 2021-11-30 2023-02-28 default ENDED -
|
||||
2.5.x 2021-05-31 2022-05-31 2023-08-31 default ENDED -
|
||||
2.6.x 2021-11-30 2022-11-30 2024-02-29 default ENDED -
|
||||
2.7.x 2022-05-31 2023-06-30 2029-06-30 extended COMMERCIAL_ONLY -
|
||||
3.0.x 2022-11-30 2023-12-31 2024-12-31 default ENDED -
|
||||
3.1.x 2023-05-31 2024-06-30 2025-06-30 default ENDED -
|
||||
3.2.x 2023-11-30 2024-12-31 2025-12-31 default ENDED -
|
||||
3.3.x 2024-05-31 2025-06-30 2026-06-30 default ENDED -
|
||||
3.4.x 2024-11-30 2025-12-31 2026-12-31 default COMMERCIAL_ONLY -
|
||||
3.5.x 2025-05-31 2026-06-30 2032-06-30 extended COMMERCIAL_ONLY -
|
||||
4.0.x 2025-11-30 2026-12-31 2027-12-31 default OSS 28
|
||||
4.1.x 2026-06-30 2027-07-31 2028-07-31 default OSS 240
|
||||
4.2.x 2026-11-30 2027-12-31 2028-12-31 default OSS 393
|
||||
@@ -0,0 +1,13 @@
|
||||
# class major: read from SpringApplication.class in the published jar (52 = Java 8, 61 = Java 17)
|
||||
# docs Java: the system requirements page of each line on docs.spring.io ("no page" = 404)
|
||||
boot major docs Java framework tomcat jackson hibernate junit jooq
|
||||
2.7.18 52 8 to 21 5.3.31 9.0.83 2.13.5 5.6.15.Final 5.8.2 3.14.16
|
||||
3.0.13 61 no page 6.0.14 10.1.16 2.14.3 6.1.7.Final 5.9.3 3.17.16
|
||||
3.1.12 61 no page 6.0.21 10.1.24 2.15.4 6.2.25.Final 5.9.3 3.18.15
|
||||
3.2.12 61 no page 6.1.15 10.1.33 2.15.4 6.4.10.Final 5.10.5 3.18.22
|
||||
3.3.13 61 17 to 23 6.1.21 10.1.42 2.17.3 6.5.3.Final 5.10.5 3.19.24
|
||||
3.4.13 61 17 to 24 6.2.15 10.1.50 2.18.5 6.6.39.Final 5.11.4 3.19.29
|
||||
3.5.16 61 17 to 25 6.2.19 10.1.55 2.21.4 6.6.53.Final 5.12.2 3.19.35
|
||||
4.0.10 61 17 to 27 7.0.11 11.0.27 3.1.8 7.2.25.Final 6.0.3 3.19.39
|
||||
4.1.3 61 17 to 27 7.0.11 11.0.27 3.1.8 7.4.15.Final 6.0.3 3.21.9
|
||||
4.2.0 61 17 to 27 7.1.0 11.0.27 3.1.8 7.4.15.Final 6.1.3 3.21.9
|
||||
@@ -0,0 +1,7 @@
|
||||
# https://calendar.spring.io/releases?start=2026-12-03&end=2027-12-03
|
||||
# open-source Spring Boot entries only ("(Enterprise)" patches left out)
|
||||
2026-12-17 Spring Boot 4.0.11
|
||||
2026-12-17 Spring Boot 4.1.4
|
||||
2026-12-17 Spring Boot 4.2.1
|
||||
4.3 GA on Maven Central: false
|
||||
4.3.x in api.spring.io generations: false
|
||||
@@ -0,0 +1,41 @@
|
||||
# same probe app, compiled with --release 17 (2.7.18: --release 8), run on six JDKs, 2026-12-03
|
||||
|
||||
== Spring Boot 2.7.18
|
||||
JDK 1.8.0_514 STARTED boot=2.7.18 framework=5.3.31 java=1.8.0_514 scanned=ScannedBean
|
||||
JDK 11.0.33.1 STARTED boot=2.7.18 framework=5.3.31 java=11.0.33.1 scanned=ScannedBean
|
||||
JDK 17.0.21.1 STARTED boot=2.7.18 framework=5.3.31 java=17.0.21.1 scanned=ScannedBean
|
||||
JDK 21.0.13.1 STARTED boot=2.7.18 framework=5.3.31 java=21.0.13.1 scanned=ScannedBean
|
||||
JDK 25.0.5.1 STARTED boot=2.7.18 framework=5.3.31 java=25.0.5.1 scanned=ScannedBean
|
||||
JDK 27.0.1.1 STARTED boot=2.7.18 framework=5.3.31 java=27.0.1.1 scanned=ScannedBean
|
||||
|
||||
== Spring Boot 3.5.16
|
||||
JDK 1.8.0_514 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 11.0.33.1 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 17.0.21.1 STARTED boot=3.5.16 framework=6.2.19 java=17.0.21.1 scanned=ScannedBean
|
||||
JDK 21.0.13.1 STARTED boot=3.5.16 framework=6.2.19 java=21.0.13.1 scanned=ScannedBean
|
||||
JDK 25.0.5.1 STARTED boot=3.5.16 framework=6.2.19 java=25.0.5.1 scanned=ScannedBean
|
||||
JDK 27.0.1.1 STARTED boot=3.5.16 framework=6.2.19 java=27.0.1.1 scanned=ScannedBean
|
||||
|
||||
== Spring Boot 4.0.10
|
||||
JDK 1.8.0_514 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 11.0.33.1 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 17.0.21.1 STARTED boot=4.0.10 framework=7.0.11 java=17.0.21.1 scanned=ScannedBean
|
||||
JDK 21.0.13.1 STARTED boot=4.0.10 framework=7.0.11 java=21.0.13.1 scanned=ScannedBean
|
||||
JDK 25.0.5.1 STARTED boot=4.0.10 framework=7.0.11 java=25.0.5.1 scanned=ScannedBean
|
||||
JDK 27.0.1.1 STARTED boot=4.0.10 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
|
||||
== Spring Boot 4.1.3
|
||||
JDK 1.8.0_514 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 11.0.33.1 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 17.0.21.1 STARTED boot=4.1.3 framework=7.0.11 java=17.0.21.1 scanned=ScannedBean
|
||||
JDK 21.0.13.1 STARTED boot=4.1.3 framework=7.0.11 java=21.0.13.1 scanned=ScannedBean
|
||||
JDK 25.0.5.1 STARTED boot=4.1.3 framework=7.0.11 java=25.0.5.1 scanned=ScannedBean
|
||||
JDK 27.0.1.1 STARTED boot=4.1.3 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
|
||||
== Spring Boot 4.2.0
|
||||
JDK 1.8.0_514 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 11.0.33.1 FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
JDK 17.0.21.1 STARTED boot=4.2.0 framework=7.1.0 java=17.0.21.1 scanned=ScannedBean
|
||||
JDK 21.0.13.1 STARTED boot=4.2.0 framework=7.1.0 java=21.0.13.1 scanned=ScannedBean
|
||||
JDK 25.0.5.1 STARTED boot=4.2.0 framework=7.1.0 java=25.0.5.1 scanned=ScannedBean
|
||||
JDK 27.0.1.1 STARTED boot=4.2.0 framework=7.1.0 java=27.0.1.1 scanned=ScannedBean
|
||||
@@ -0,0 +1,20 @@
|
||||
# the other direction: the application itself compiled for a newer Java, run on JDK 27
|
||||
boot 2.7.18 --release 21 STARTED boot=2.7.18 framework=5.3.31 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 2.7.18 --release 25 FAILED Unsupported class file major version 69
|
||||
boot 2.7.18 --release 27 FAILED Unsupported class file major version 71
|
||||
boot 3.5.16 --release 21 STARTED boot=3.5.16 framework=6.2.19 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 3.5.16 --release 25 STARTED boot=3.5.16 framework=6.2.19 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 3.5.16 --release 27 STARTED boot=3.5.16 framework=6.2.19 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.0.10 --release 21 STARTED boot=4.0.10 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.0.10 --release 25 STARTED boot=4.0.10 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.0.10 --release 27 STARTED boot=4.0.10 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.1.3 --release 21 STARTED boot=4.1.3 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.1.3 --release 25 STARTED boot=4.1.3 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.1.3 --release 27 STARTED boot=4.1.3 framework=7.0.11 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.2.0 --release 21 STARTED boot=4.2.0 framework=7.1.0 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.2.0 --release 25 STARTED boot=4.2.0 framework=7.1.0 java=27.0.1.1 scanned=ScannedBean
|
||||
boot 4.2.0 --release 27 STARTED boot=4.2.0 framework=7.1.0 java=27.0.1.1 scanned=ScannedBean
|
||||
|
||||
# below the floor: the build with --release 11 against Boot 4.2.0, then the jar on JDK 11
|
||||
mvn package: BUILD SUCCESS
|
||||
run on JDK 11: FAILED UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0)
|
||||
@@ -0,0 +1,90 @@
|
||||
# configuration metadata of every org.springframework.boot jar in each BOM, 4.0.10 -> 4.2.0
|
||||
4.0.10 declares 2618 properties, 4.2.0 declares 2810 (193 new names)
|
||||
|
||||
usable on 4.0.10, unusable or absent on 4.2.0: 8
|
||||
logging.file.clean-history-on-start -> logging.logback.rollingpolicy.clean-history-on-start
|
||||
logging.file.max-history -> logging.logback.rollingpolicy.max-history
|
||||
logging.file.max-size -> logging.logback.rollingpolicy.max-file-size
|
||||
logging.file.total-size-cap -> logging.logback.rollingpolicy.total-size-cap
|
||||
logging.pattern.rolling-file-name -> logging.logback.rollingpolicy.file-name-pattern
|
||||
management.metrics.observations.ignored-meters -> management.metrics.observations.include-active-long-task-timer
|
||||
spring.data.redis.lettuce.cluster.refresh.adaptive (no replacement listed)
|
||||
spring.datasource.oracleucp.role-name (not in metadata)
|
||||
|
||||
newly deprecated (still bound) on 4.2.0: 76
|
||||
management.appoptics.metrics.export.api-token (no replacement listed)
|
||||
management.appoptics.metrics.export.batch-size (no replacement listed)
|
||||
management.appoptics.metrics.export.connect-timeout (no replacement listed)
|
||||
management.appoptics.metrics.export.floor-times (no replacement listed)
|
||||
management.appoptics.metrics.export.host-tag (no replacement listed)
|
||||
management.appoptics.metrics.export.uri (no replacement listed)
|
||||
management.dynatrace.metrics.export.v1.device-id (no replacement listed)
|
||||
management.dynatrace.metrics.export.v1.group (no replacement listed)
|
||||
management.dynatrace.metrics.export.v1.technology-type (no replacement listed)
|
||||
server.forward-headers-strategy -> server.request.header.forwarded.strategy
|
||||
server.tomcat.additional-tld-skip-patterns -> server.tomcat.servlet.additional-tld-skip-patterns
|
||||
server.tomcat.redirect-context-root -> server.tomcat.servlet.redirect-context-root
|
||||
server.tomcat.use-relative-redirects -> server.tomcat.servlet.use-relative-redirects
|
||||
spring.devtools.livereload.enabled (no replacement listed)
|
||||
spring.devtools.livereload.port (no replacement listed)
|
||||
spring.mvc.pathmatch.matching-strategy (no replacement listed)
|
||||
spring.pulsar.admin.authentication.param (no replacement listed)
|
||||
spring.pulsar.admin.authentication.plugin-class-name (no replacement listed)
|
||||
spring.pulsar.admin.connection-timeout (no replacement listed)
|
||||
spring.pulsar.admin.read-timeout (no replacement listed)
|
||||
spring.pulsar.admin.request-timeout (no replacement listed)
|
||||
spring.pulsar.admin.service-url (no replacement listed)
|
||||
spring.pulsar.client.authentication.param (no replacement listed)
|
||||
spring.pulsar.client.authentication.plugin-class-name (no replacement listed)
|
||||
spring.pulsar.client.connection-timeout (no replacement listed)
|
||||
spring.pulsar.client.failover.backup-clusters (no replacement listed)
|
||||
spring.pulsar.client.failover.check-interval (no replacement listed)
|
||||
spring.pulsar.client.failover.delay (no replacement listed)
|
||||
spring.pulsar.client.failover.policy (no replacement listed)
|
||||
spring.pulsar.client.failover.switch-back-delay (no replacement listed)
|
||||
spring.pulsar.client.lookup-timeout (no replacement listed)
|
||||
spring.pulsar.client.operation-timeout (no replacement listed)
|
||||
spring.pulsar.client.service-url (no replacement listed)
|
||||
spring.pulsar.client.threads.io (no replacement listed)
|
||||
spring.pulsar.client.threads.listener (no replacement listed)
|
||||
spring.pulsar.consumer.dead-letter-policy.dead-letter-topic (no replacement listed)
|
||||
spring.pulsar.consumer.dead-letter-policy.initial-subscription-name (no replacement listed)
|
||||
spring.pulsar.consumer.dead-letter-policy.max-redeliver-count (no replacement listed)
|
||||
spring.pulsar.consumer.dead-letter-policy.retry-letter-topic (no replacement listed)
|
||||
spring.pulsar.consumer.name (no replacement listed)
|
||||
spring.pulsar.consumer.priority-level (no replacement listed)
|
||||
spring.pulsar.consumer.read-compacted (no replacement listed)
|
||||
spring.pulsar.consumer.retry-enable (no replacement listed)
|
||||
spring.pulsar.consumer.subscription.initial-position (no replacement listed)
|
||||
spring.pulsar.consumer.subscription.mode (no replacement listed)
|
||||
spring.pulsar.consumer.subscription.topics-mode (no replacement listed)
|
||||
spring.pulsar.consumer.subscription.type (no replacement listed)
|
||||
spring.pulsar.consumer.topics (no replacement listed)
|
||||
spring.pulsar.consumer.topics-pattern (no replacement listed)
|
||||
spring.pulsar.defaults.topic.namespace (no replacement listed)
|
||||
spring.pulsar.defaults.topic.tenant (no replacement listed)
|
||||
spring.pulsar.function.fail-fast (no replacement listed)
|
||||
spring.pulsar.function.propagate-failures (no replacement listed)
|
||||
spring.pulsar.function.propagate-stop-failures (no replacement listed)
|
||||
spring.pulsar.listener.concurrency (no replacement listed)
|
||||
spring.pulsar.listener.observation-enabled (no replacement listed)
|
||||
spring.pulsar.producer.access-mode (no replacement listed)
|
||||
spring.pulsar.producer.batching-enabled (no replacement listed)
|
||||
spring.pulsar.producer.cache.expire-after-access (no replacement listed)
|
||||
spring.pulsar.producer.cache.initial-capacity (no replacement listed)
|
||||
spring.pulsar.producer.cache.maximum-size (no replacement listed)
|
||||
spring.pulsar.producer.chunking-enabled (no replacement listed)
|
||||
spring.pulsar.producer.compression-type (no replacement listed)
|
||||
spring.pulsar.producer.hashing-scheme (no replacement listed)
|
||||
spring.pulsar.producer.message-routing-mode (no replacement listed)
|
||||
spring.pulsar.producer.name (no replacement listed)
|
||||
spring.pulsar.producer.send-timeout (no replacement listed)
|
||||
spring.pulsar.producer.topic-name (no replacement listed)
|
||||
spring.pulsar.reader.name (no replacement listed)
|
||||
spring.pulsar.reader.read-compacted (no replacement listed)
|
||||
spring.pulsar.reader.subscription-name (no replacement listed)
|
||||
spring.pulsar.reader.subscription-role-prefix (no replacement listed)
|
||||
spring.pulsar.reader.topics (no replacement listed)
|
||||
spring.pulsar.template.observations-enabled (no replacement listed)
|
||||
spring.pulsar.transaction.enabled (no replacement listed)
|
||||
spring.rabbitmq.ssl.verify-hostname (no replacement listed)
|
||||
@@ -0,0 +1,15 @@
|
||||
$ unzip -p probe.jar META-INF/MANIFEST.MF | grep -E 'Spring-Boot-Version|Build-Jdk'
|
||||
Build-Jdk-Spec: 25
|
||||
Spring-Boot-Version: 4.2.0
|
||||
|
||||
$ mvn help:evaluate -Dexpression=boot.version -q -DforceStdout
|
||||
4.2.0
|
||||
|
||||
|
||||
$ mvn dependency:tree | grep -E 'spring-boot-starter:|spring-core:'
|
||||
\- org.springframework.boot:spring-boot-starter:jar:4.2.0:compile
|
||||
| +- org.springframework:spring-core:jar:7.1.0:compile
|
||||
|
||||
$ java -jar probe.jar (the banner line and the probe line)
|
||||
:: Spring Boot :: (v4.2.0)
|
||||
STARTED boot=4.2.0 framework=7.1.0 java=25.0.5.1 scanned=ScannedBean
|
||||
@@ -0,0 +1,32 @@
|
||||
== 4.0.10: java -Djarmode=layertools -jar probe.jar list
|
||||
Warning: This command is deprecated. Use '-Djarmode=tools list-layers' instead.
|
||||
|
||||
dependencies
|
||||
spring-boot-loader
|
||||
snapshot-dependencies
|
||||
application
|
||||
exit code 0
|
||||
== 4.0.10: java -Djarmode=tools -jar probe.jar list-layers
|
||||
dependencies
|
||||
spring-boot-loader
|
||||
snapshot-dependencies
|
||||
application
|
||||
|
||||
== 4.1.3: java -Djarmode=layertools -jar probe.jar list
|
||||
Error: Unsupported jarmode 'layertools'
|
||||
exit code 1
|
||||
== 4.1.3: java -Djarmode=tools -jar probe.jar list-layers
|
||||
dependencies
|
||||
spring-boot-loader
|
||||
snapshot-dependencies
|
||||
application
|
||||
|
||||
== 4.2.0: java -Djarmode=layertools -jar probe.jar list
|
||||
Error: Unsupported jarmode 'layertools'
|
||||
exit code 1
|
||||
== 4.2.0: java -Djarmode=tools -jar probe.jar list-layers
|
||||
dependencies
|
||||
spring-boot-loader
|
||||
snapshot-dependencies
|
||||
application
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# class file major version of org/jooq/DSLContext.class (61 = Java 17, 65 = Java 21)
|
||||
Spring Boot 4.0.10 manages jOOQ 3.19.39 -> class major 61
|
||||
Spring Boot 4.1.3 manages jOOQ 3.21.9 -> class major 65
|
||||
Spring Boot 4.2.0 manages jOOQ 3.21.9 -> class major 65
|
||||
@@ -0,0 +1,349 @@
|
||||
{
|
||||
"_embedded" : {
|
||||
"generations" : [ {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/1.5.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "1.5.x",
|
||||
"initialReleaseDate" : "2017-01-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2019-08-31",
|
||||
"commercialSupportEndDate" : "2020-11-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "1.5.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.0.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.0.x",
|
||||
"initialReleaseDate" : "2018-03-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2019-03-31",
|
||||
"commercialSupportEndDate" : "2020-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.0.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.1.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.1.x",
|
||||
"initialReleaseDate" : "2018-10-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2019-10-31",
|
||||
"commercialSupportEndDate" : "2021-01-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.1.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.2.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.2.x",
|
||||
"initialReleaseDate" : "2019-10-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2020-10-31",
|
||||
"commercialSupportEndDate" : "2022-01-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.2.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.3.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.3.x",
|
||||
"initialReleaseDate" : "2020-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2021-05-31",
|
||||
"commercialSupportEndDate" : "2022-08-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.3.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.4.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.4.x",
|
||||
"initialReleaseDate" : "2020-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2021-11-30",
|
||||
"commercialSupportEndDate" : "2023-02-28",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.4.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.5.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.5.x",
|
||||
"initialReleaseDate" : "2021-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2022-05-31",
|
||||
"commercialSupportEndDate" : "2023-08-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.5.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.6.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.6.x",
|
||||
"initialReleaseDate" : "2021-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2022-11-30",
|
||||
"commercialSupportEndDate" : "2024-02-29",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.6.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.7.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.7.x",
|
||||
"initialReleaseDate" : "2022-05-31",
|
||||
"support" : "extended",
|
||||
"ossSupportEndDate" : "2023-06-30",
|
||||
"commercialSupportEndDate" : "2029-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.7.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "2.7.37"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.0.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.0.x",
|
||||
"initialReleaseDate" : "2022-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2023-12-31",
|
||||
"commercialSupportEndDate" : "2024-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.0.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.0.20"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.1.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.1.x",
|
||||
"initialReleaseDate" : "2023-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2024-06-30",
|
||||
"commercialSupportEndDate" : "2025-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.1.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.1.21"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.2.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.2.x",
|
||||
"initialReleaseDate" : "2023-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2024-12-31",
|
||||
"commercialSupportEndDate" : "2025-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.2.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.2.19"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.3.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.3.x",
|
||||
"initialReleaseDate" : "2024-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2025-06-30",
|
||||
"commercialSupportEndDate" : "2026-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.3.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.3.20.1"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.4.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.4.x",
|
||||
"initialReleaseDate" : "2024-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2025-12-31",
|
||||
"commercialSupportEndDate" : "2026-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.4.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.4.20"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.5.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.5.x",
|
||||
"initialReleaseDate" : "2025-05-31",
|
||||
"support" : "extended",
|
||||
"ossSupportEndDate" : "2026-06-30",
|
||||
"commercialSupportEndDate" : "2032-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.5.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "3.5.16",
|
||||
"enterprise" : "3.5.19"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/4.0.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "4.0.x",
|
||||
"initialReleaseDate" : "2025-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2026-12-31",
|
||||
"commercialSupportEndDate" : "2027-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "4.0.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "4.0.10",
|
||||
"enterprise" : "4.0.9.1"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/4.1.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "4.1.x",
|
||||
"initialReleaseDate" : "2026-06-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2027-07-31",
|
||||
"commercialSupportEndDate" : "2028-07-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "4.1.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "4.1.3",
|
||||
"enterprise" : "4.1.2.1"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/4.2.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "4.2.x",
|
||||
"initialReleaseDate" : "2026-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2027-12-31",
|
||||
"commercialSupportEndDate" : "2028-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "4.2.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "4.2.0"
|
||||
}
|
||||
} ]
|
||||
},
|
||||
"_links" : {
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ankurm</groupId>
|
||||
<artifactId>boot-versions</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<description>Spring Boot versions, support dates and Java baselines read from primary sources</description>
|
||||
|
||||
<properties>
|
||||
<java.version>25</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>tools.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- One application, built against any Boot line:
|
||||
mvn -f probe/pom.xml package -Dboot.version=4.2.0 -Djava.release=17
|
||||
A parent version cannot be a property, so the BOM is imported instead. -->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.ankurm</groupId>
|
||||
<artifactId>probe</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<properties>
|
||||
<boot.version>4.2.0</boot.version>
|
||||
<java.release>17</java.release>
|
||||
<maven.compiler.release>${java.release}</maven.compiler.release>
|
||||
<maven.compiler.parameters>true</maven.compiler.parameters>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<directory>${project.basedir}/target/boot-${boot.version}-release-${java.release}</directory>
|
||||
<finalName>probe</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.15.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<mainClass>com.ankurm.probe.ProbeApplication</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ankurm.probe;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringBootVersion;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.SpringVersion;
|
||||
|
||||
/** Boots a context (with component scanning) and prints what is really running. Java 8 syntax on purpose. */
|
||||
@SpringBootApplication
|
||||
public class ProbeApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try (ConfigurableApplicationContext context = SpringApplication.run(ProbeApplication.class, args)) {
|
||||
System.out.println("STARTED boot=" + SpringBootVersion.getVersion()
|
||||
+ " framework=" + SpringVersion.getVersion()
|
||||
+ " java=" + System.getProperty("java.version")
|
||||
+ " scanned=" + context.getBean(ScannedBean.class).getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ankurm.probe;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/** Found only if Spring can read this class file during component scanning. */
|
||||
@Component
|
||||
public class ScannedBean {
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
# shared by the other scripts
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
TODAY="${TODAY:-$(date -u +%F)}"
|
||||
# drop JVM banners and anything machine specific from captured output
|
||||
clean() { sed -e '/^Picked up /d' -e "s#$PWD/##g" -e "s#$HOME#~#g"; }
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the probe app against each Boot line and boots it on each JDK.
|
||||
# Set JDK8 JDK11 JDK17 JDK21 JDK25 JDK27 to the JDK home directories (Temurin was used here).
|
||||
source "$(dirname "$0")/env.sh"
|
||||
unset _JAVA_OPTIONS
|
||||
JDK8=${JDK8:?} JDK11=${JDK11:?} JDK17=${JDK17:?} JDK21=${JDK21:?} JDK25=${JDK25:?} JDK27=${JDK27:?}
|
||||
BOOTS="2.7.18 3.5.16 4.0.10 4.1.3 4.2.0"
|
||||
|
||||
build() { # boot release javac-jdk
|
||||
JAVA_HOME="$3" mvn -B -q -f probe/pom.xml package -Dboot.version="$1" -Djava.release="$2" >/dev/null
|
||||
}
|
||||
boot() { # jdk jar: one result line
|
||||
local log; log=$("$1/bin/java" -jar "$2" --logging.level.root=WARN --spring.main.banner-mode=off 2>&1) || true
|
||||
if grep -q '^STARTED' <<<"$log"; then
|
||||
grep '^STARTED' <<<"$log"
|
||||
else
|
||||
printf 'FAILED '
|
||||
grep -o -m1 -E 'Unsupported class file major version [0-9]+' <<<"$log" | head -1 | grep . \
|
||||
|| grep -o -m1 -E 'UnsupportedClassVersionError: [^ ]+ has been compiled by a more recent version of the Java Runtime \(class file version [0-9.]+\)' <<<"$log" \
|
||||
|| tail -n1 <<<"$log"
|
||||
fi
|
||||
}
|
||||
for v in $BOOTS; do
|
||||
rel=17; [[ $v == 2.* ]] && rel=8
|
||||
build "$v" "$rel" "$JDK25"
|
||||
done
|
||||
|
||||
{
|
||||
echo "# same probe app, compiled with --release 17 (2.7.18: --release 8), run on six JDKs, $TODAY"
|
||||
for v in $BOOTS; do
|
||||
rel=17; [[ $v == 2.* ]] && rel=8
|
||||
echo; echo "== Spring Boot $v"
|
||||
for j in "$JDK8" "$JDK11" "$JDK17" "$JDK21" "$JDK25" "$JDK27"; do
|
||||
n=$("$j/bin/java" -version 2>&1 | grep -m1 ' version ' | cut -d'"' -f2)
|
||||
printf 'JDK %-10s ' "$n"; boot "$j" "probe/target/boot-$v-release-$rel/probe.jar"
|
||||
done
|
||||
done
|
||||
} | clean | tee output/05-boot-matrix.txt
|
||||
|
||||
{
|
||||
echo "# the other direction: the application itself compiled for a newer Java, run on JDK 27"
|
||||
for v in $BOOTS; do
|
||||
for rel in 21 25 27; do
|
||||
jdk=$JDK25; [[ $rel == 27 ]] && jdk=$JDK27
|
||||
build "$v" "$rel" "$jdk"
|
||||
printf 'boot %-7s --release %s ' "$v" "$rel"; boot "$JDK27" "probe/target/boot-$v-release-$rel/probe.jar"
|
||||
done
|
||||
done
|
||||
echo
|
||||
echo "# below the floor: the build with --release 11 against Boot 4.2.0, then the jar on JDK 11"
|
||||
JAVA_HOME="$JDK25" mvn -B -f probe/pom.xml package -Dboot.version=4.2.0 -Djava.release=11 2>&1 \
|
||||
| grep -m1 -E 'BUILD (SUCCESS|FAILURE)' | sed 's/^\[[A-Z]*\] /mvn package: /'
|
||||
printf 'run on JDK 11: '; boot "$JDK11" probe/target/boot-4.2.0-release-11/probe.jar
|
||||
} | clean | sed "s#$(dirname "$PWD")/##g" | tee output/06-java-limits.txt
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates output/01..04 and 07 from Maven Central, api.spring.io, calendar.spring.io and docs.spring.io.
|
||||
source "$(dirname "$0")/env.sh"
|
||||
mvn -B -q package dependency:build-classpath -Dmdep.outputFile=target/cp.txt >/dev/null
|
||||
CP="target/classes:$(cat target/cp.txt)"
|
||||
run() { java -cp "$CP" com.ankurm.bootversions.VersionReport "$1" "$TODAY" | clean | tee "output/$2"; }
|
||||
run latest 01-maven-latest.txt
|
||||
run support 02-support-dates.txt
|
||||
run baselines 03-bom-and-java-baselines.txt
|
||||
run calendar 04-calendar-and-4.3.txt
|
||||
run properties 07-properties-4.0-to-4.2.txt
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates every file in output/. Needs network access and the JDK8..JDK27 variables (see matrix.sh).
|
||||
set -euo pipefail
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
JAVA_HOME="${JDK25:?}" PATH="$JDK25/bin:$PATH" "$here/report.sh"
|
||||
"$here/matrix.sh"
|
||||
"$here/upgrade-and-check.sh"
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run after matrix.sh. 08: how to read the version of a project and of a jar. 09: layertools, gone since 4.1.
|
||||
source "$(dirname "$0")/env.sh"
|
||||
unset _JAVA_OPTIONS
|
||||
JAVA_HOME=${JDK25:?}
|
||||
export JAVA_HOME
|
||||
JAR=probe/target/boot-4.2.0-release-17/probe.jar
|
||||
M="mvn -B -f probe/pom.xml -Dboot.version=4.2.0"
|
||||
{
|
||||
echo "\$ unzip -p probe.jar META-INF/MANIFEST.MF | grep -E 'Spring-Boot-Version|Build-Jdk'"
|
||||
unzip -p $JAR META-INF/MANIFEST.MF | grep -E 'Spring-Boot-Version|Build-Jdk' | tr -d '\r'
|
||||
echo
|
||||
echo "\$ mvn help:evaluate -Dexpression=boot.version -q -DforceStdout"
|
||||
$M help:evaluate -Dexpression=boot.version -q -DforceStdout | grep -v '^Picked'; echo
|
||||
echo
|
||||
echo "\$ mvn dependency:tree | grep -E 'spring-boot-starter:|spring-core:'"
|
||||
$M dependency:tree | grep -E 'spring-boot-starter:|spring-core:' | sed 's/^\[INFO\] //'
|
||||
echo
|
||||
echo "\$ java -jar probe.jar (the banner line and the probe line)"
|
||||
"$JAVA_HOME/bin/java" -jar $JAR 2>&1 | grep -E ':: Spring Boot ::|^STARTED'
|
||||
} | clean | tee output/08-which-version.txt
|
||||
|
||||
{
|
||||
for v in 4.0.10 4.1.3 4.2.0; do
|
||||
j=probe/target/boot-$v-release-17/probe.jar
|
||||
echo "== $v: java -Djarmode=layertools -jar probe.jar list"
|
||||
code=0; out=$("$JAVA_HOME/bin/java" -Djarmode=layertools -jar $j list 2>&1) || code=$?
|
||||
grep -v '^Picked' <<<"$out" | head -n 6; echo "exit code $code"
|
||||
echo "== $v: java -Djarmode=tools -jar probe.jar list-layers"
|
||||
"$JAVA_HOME/bin/java" -Djarmode=tools -jar $j list-layers 2>&1 | grep -v '^Picked' || true
|
||||
echo
|
||||
done
|
||||
} | clean | tee output/09-layertools-4.0-to-4.2.txt
|
||||
|
||||
{
|
||||
set +o pipefail
|
||||
echo "# class file major version of org/jooq/DSLContext.class (61 = Java 17, 65 = Java 21)"
|
||||
for pair in 4.0.10:3.19.39 4.1.3:3.21.9 4.2.0:3.21.9; do
|
||||
j=${pair#*:}
|
||||
mvn -B -q dependency:get -Dartifact=org.jooq:jooq:$j >/dev/null
|
||||
repo="$HOME/.m2/repository/org/jooq/jooq/$j/jooq-$j.jar"
|
||||
major=$(unzip -p "$repo" org/jooq/DSLContext.class | head -c 8 | od -An -tu1 | awk '{print $7*256+$8}')
|
||||
echo "Spring Boot ${pair%:*} manages jOOQ $j -> class major $major"
|
||||
done
|
||||
} | clean | tee output/10-jooq-java-floor.txt
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ankurm.bootversions;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/** spring-boot-dependencies: the version properties and the Boot modules one release manages. */
|
||||
public record Bom(String version, Map<String, String> properties, List<String> bootModules) {
|
||||
|
||||
static Bom read(Central central, String version) throws Exception {
|
||||
var path = central.file("org/springframework/boot/spring-boot-dependencies/" + version
|
||||
+ "/spring-boot-dependencies-" + version + ".pom");
|
||||
return parse(version, Files.readAllBytes(path));
|
||||
}
|
||||
|
||||
static Bom parse(String version, byte[] pom) throws Exception {
|
||||
Element project = Central.xml(pom).getDocumentElement();
|
||||
Map<String, String> properties = new LinkedHashMap<>();
|
||||
Element props = Central.child(project, "properties");
|
||||
for (var n = props.getFirstChild(); n != null; n = n.getNextSibling()) {
|
||||
if (n instanceof Element e) {
|
||||
properties.put(e.getTagName(), e.getTextContent().trim());
|
||||
}
|
||||
}
|
||||
List<String> modules = new ArrayList<>();
|
||||
var dependencies = project.getElementsByTagName("dependency");
|
||||
for (int i = 0; i < dependencies.getLength(); i++) {
|
||||
Element d = (Element) dependencies.item(i);
|
||||
if ("org.springframework.boot".equals(Central.child(d, "groupId").getTextContent())
|
||||
&& Central.child(d, "classifier") == null) {
|
||||
String id = Central.child(d, "artifactId").getTextContent();
|
||||
if (!modules.contains(id)) {
|
||||
modules.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Bom(version, properties, modules);
|
||||
}
|
||||
|
||||
String property(String name) {
|
||||
return properties.getOrDefault(name, "-");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.ankurm.bootversions;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/** Reads Maven Central directly. No search API: only repository files. */
|
||||
public final class Central {
|
||||
|
||||
static final String REPO = "https://repo1.maven.org/maven2/";
|
||||
private static final Pattern GA = Pattern.compile("\\d+\\.\\d+\\.\\d+(\\.RELEASE)?");
|
||||
|
||||
private final HttpClient http = HttpClient.newBuilder()
|
||||
.followRedirects(HttpClient.Redirect.NORMAL)
|
||||
.proxy(java.net.ProxySelector.getDefault())
|
||||
.build();
|
||||
private final Path cache = Path.of("target", "cache");
|
||||
|
||||
public String text(String url) throws IOException, InterruptedException {
|
||||
HttpResponse<String> r = send(request(url).build(), HttpResponse.BodyHandlers.ofString());
|
||||
check(url, r.statusCode());
|
||||
return r.body();
|
||||
}
|
||||
|
||||
/** Maven Central answers 429 when asked too fast, so wait and try again. */
|
||||
private <T> HttpResponse<T> send(HttpRequest request, HttpResponse.BodyHandler<T> handler)
|
||||
throws IOException, InterruptedException {
|
||||
HttpResponse<T> r = http.send(request, handler);
|
||||
for (int attempt = 1; attempt <= 6 && r.statusCode() == 429; attempt++) {
|
||||
Thread.sleep(5_000L * attempt);
|
||||
r = http.send(request, handler);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Downloads a repository file once and keeps it under target/cache. */
|
||||
public Path file(String path) throws IOException, InterruptedException {
|
||||
Path target = cache.resolve(path);
|
||||
if (!Files.exists(target)) {
|
||||
Files.createDirectories(target.getParent());
|
||||
HttpResponse<byte[]> r = send(request(REPO + path).build(), HttpResponse.BodyHandlers.ofByteArray());
|
||||
check(path, r.statusCode());
|
||||
Files.write(target, r.body());
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
/** The day the file landed on Maven Central, in UTC, from its Last-Modified header. */
|
||||
public LocalDate publishedOn(String path) throws IOException, InterruptedException {
|
||||
HttpResponse<Void> r = send(request(REPO + path).method("HEAD", HttpRequest.BodyPublishers.noBody()).build(),
|
||||
HttpResponse.BodyHandlers.discarding());
|
||||
check(path, r.statusCode());
|
||||
String header = r.headers().firstValue("last-modified").orElseThrow();
|
||||
return ZonedDateTime.parse(header, DateTimeFormatter.RFC_1123_DATE_TIME)
|
||||
.withZoneSameInstant(ZoneOffset.UTC).toLocalDate();
|
||||
}
|
||||
|
||||
/** All GA versions (no -M, -RC, -SNAPSHOT; up to 2.3 they end in .RELEASE), oldest first. */
|
||||
public List<String> gaVersions(String groupPath, String artifact) throws Exception {
|
||||
Document doc = xml(text(REPO + groupPath + "/" + artifact + "/maven-metadata.xml").getBytes());
|
||||
var nodes = doc.getElementsByTagName("version");
|
||||
List<String> all = new ArrayList<>();
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
all.add(nodes.item(i).getTextContent().trim());
|
||||
}
|
||||
return gaOnly(all);
|
||||
}
|
||||
|
||||
static List<String> gaOnly(List<String> versions) {
|
||||
return versions.stream().filter(v -> GA.matcher(v).matches()).sorted(byVersion()).toList();
|
||||
}
|
||||
|
||||
static Comparator<String> byVersion() {
|
||||
return Comparator.<String>comparingInt(v -> part(v, 0))
|
||||
.thenComparingInt(v -> part(v, 1))
|
||||
.thenComparingInt(v -> part(v, 2));
|
||||
}
|
||||
|
||||
private static int part(String v, int i) {
|
||||
return Integer.parseInt(v.split("\\.")[i]);
|
||||
}
|
||||
|
||||
static Document xml(byte[] bytes) throws Exception {
|
||||
var factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
return factory.newDocumentBuilder().parse(new ByteArrayInputStream(bytes));
|
||||
}
|
||||
|
||||
static Element child(Element parent, String name) {
|
||||
for (Node n = parent.getFirstChild(); n != null; n = n.getNextSibling()) {
|
||||
if (n instanceof Element e && e.getTagName().equals(name)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static HttpRequest.Builder request(String url) {
|
||||
return HttpRequest.newBuilder(URI.create(url)).header("User-Agent", "boot-versions-report");
|
||||
}
|
||||
|
||||
private static void check(String what, int status) throws IOException {
|
||||
if (status != 200) {
|
||||
throw new IOException("HTTP " + status + " for " + what);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ankurm.bootversions;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import tools.jackson.databind.JsonNode;
|
||||
import tools.jackson.databind.json.JsonMapper;
|
||||
|
||||
/** One "generation" (minor line) as published by api.spring.io. */
|
||||
public record Support(String line, LocalDate listedRelease, LocalDate ossEnd,
|
||||
LocalDate commercialEnd, String kind) {
|
||||
|
||||
public enum Status { OSS, COMMERCIAL_ONLY, ENDED }
|
||||
|
||||
/** The end date itself still counts as supported. */
|
||||
public Status statusOn(LocalDate day) {
|
||||
if (!day.isAfter(ossEnd)) {
|
||||
return Status.OSS;
|
||||
}
|
||||
return day.isAfter(commercialEnd) ? Status.ENDED : Status.COMMERCIAL_ONLY;
|
||||
}
|
||||
|
||||
public long ossDaysLeft(LocalDate day) {
|
||||
return ChronoUnit.DAYS.between(day, ossEnd);
|
||||
}
|
||||
|
||||
public static List<Support> parse(String generationsJson) {
|
||||
List<Support> out = new ArrayList<>();
|
||||
JsonNode root = JsonMapper.shared().readTree(generationsJson);
|
||||
for (JsonNode g : root.path("_embedded").path("generations")) {
|
||||
out.add(new Support(
|
||||
g.path("name").asString(),
|
||||
LocalDate.parse(g.path("initialReleaseDate").asString()),
|
||||
LocalDate.parse(g.path("ossSupportEndDate").asString()),
|
||||
LocalDate.parse(g.path("commercialSupportEndDate").asString()),
|
||||
g.path("support").asString()));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.ankurm.bootversions;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.regex.Pattern;
|
||||
import tools.jackson.databind.JsonNode;
|
||||
import tools.jackson.databind.json.JsonMapper;
|
||||
|
||||
/**
|
||||
* Prints the tables behind the article. Usage:
|
||||
* {@code VersionReport latest|support|baselines|calendar|properties [yyyy-MM-dd]}
|
||||
*/
|
||||
public final class VersionReport {
|
||||
|
||||
static final List<String> LINES = List.of("2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "4.0", "4.1", "4.2");
|
||||
private static final String BOOT = "org/springframework/boot/";
|
||||
private static final String API = "https://api.spring.io/projects/spring-boot/generations";
|
||||
|
||||
private final Central central = new Central();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String command = args.length > 0 ? args[0] : "latest";
|
||||
LocalDate today = args.length > 1 ? LocalDate.parse(args[1]) : LocalDate.now();
|
||||
var report = new VersionReport();
|
||||
switch (command) {
|
||||
case "latest" -> report.latest(today);
|
||||
case "support" -> report.support(today);
|
||||
case "baselines" -> report.baselines();
|
||||
case "calendar" -> report.calendar(today);
|
||||
case "properties" -> report.properties("4.0.10", "4.2.0");
|
||||
default -> throw new IllegalArgumentException("unknown command " + command);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> latestPatchPerLine() throws Exception {
|
||||
Map<String, String> latest = new LinkedHashMap<>();
|
||||
List<String> all = central.gaVersions("org/springframework/boot", "spring-boot-dependencies");
|
||||
for (String line : LINES) {
|
||||
all.stream().filter(v -> v.startsWith(line + ".")).reduce((a, b) -> b)
|
||||
.ifPresent(v -> latest.put(line, v));
|
||||
}
|
||||
return latest;
|
||||
}
|
||||
|
||||
private static String pom(String version) {
|
||||
return BOOT + "spring-boot-dependencies/" + version + "/spring-boot-dependencies-" + version + ".pom";
|
||||
}
|
||||
|
||||
void latest(LocalDate today) throws Exception {
|
||||
List<String> all = central.gaVersions("org/springframework/boot", "spring-boot-dependencies");
|
||||
System.out.println("# Maven Central, org.springframework.boot:spring-boot-dependencies, read on " + today);
|
||||
System.out.println("latest GA overall: " + all.getLast());
|
||||
System.out.printf("%-6s %-12s %-16s %-13s %s%n", "line", "x.y.0 date", "latest patch", "patch date", "patches");
|
||||
for (var e : latestPatchPerLine().entrySet()) {
|
||||
long count = all.stream().filter(v -> v.startsWith(e.getKey() + ".")).count();
|
||||
String first = all.contains(e.getKey() + ".0") ? e.getKey() + ".0" : e.getKey() + ".0.RELEASE";
|
||||
System.out.printf("%-6s %-12s %-16s %-13s %d%n", e.getKey(),
|
||||
central.publishedOn(pom(first)), e.getValue(),
|
||||
central.publishedOn(pom(e.getValue())), count);
|
||||
}
|
||||
}
|
||||
|
||||
void support(LocalDate today) throws Exception {
|
||||
String json = central.text(API);
|
||||
Files.createDirectories(Path.of("output"));
|
||||
Files.writeString(Path.of("output", "api-generations.json"), json);
|
||||
System.out.println("# " + API + ", status computed for " + today);
|
||||
System.out.printf("%-7s %-13s %-12s %-15s %-9s %-16s %s%n", "line", "listed start", "OSS ends",
|
||||
"commercial ends", "kind", "status", "OSS days left");
|
||||
for (Support s : Support.parse(json)) {
|
||||
if (s.line().startsWith("1.")) {
|
||||
continue;
|
||||
}
|
||||
var status = s.statusOn(today);
|
||||
System.out.printf("%-7s %-13s %-12s %-15s %-9s %-16s %s%n", s.line(), s.listedRelease(), s.ossEnd(),
|
||||
s.commercialEnd(), s.kind(), status, status == Support.Status.OSS ? s.ossDaysLeft(today) : "-");
|
||||
}
|
||||
}
|
||||
|
||||
/** The class file major version of SpringApplication is the real compile floor of a release. */
|
||||
private int classMajor(String version) throws Exception {
|
||||
Path jar = central.file(BOOT + "spring-boot/" + version + "/spring-boot-" + version + ".jar");
|
||||
try (var file = new JarFile(jar.toFile());
|
||||
var in = new DataInputStream(file.getInputStream(
|
||||
file.getEntry("org/springframework/boot/SpringApplication.class")))) {
|
||||
in.readInt();
|
||||
in.readUnsignedShort();
|
||||
return in.readUnsignedShort();
|
||||
}
|
||||
}
|
||||
|
||||
private String documentedJava(String line, String version) throws InterruptedException {
|
||||
try {
|
||||
String url = "https://docs.spring.io/spring-boot/" + switch (line) {
|
||||
case "2.7" -> "docs/2.7.18/reference/html/getting-started.html";
|
||||
case "4.2" -> "system-requirements.html";
|
||||
default -> line + "/system-requirements.html";
|
||||
};
|
||||
String page = central.text(url).replaceAll("<[^>]+>", "").replaceAll("\\s+", " ");
|
||||
var m = Pattern.compile("Spring Boot " + Pattern.quote(version)
|
||||
+ " requires (?:at least )?Java (\\d+) and is compatible (?:with )?(?:versions )?up to and including (?:Java )?(\\d+)")
|
||||
.matcher(page);
|
||||
return m.find() ? m.group(1) + " to " + m.group(2) : "not parsed";
|
||||
} catch (IOException e) {
|
||||
return "no page";
|
||||
}
|
||||
}
|
||||
|
||||
void baselines() throws Exception {
|
||||
System.out.println("# class major: read from SpringApplication.class in the published jar (52 = Java 8, 61 = Java 17)");
|
||||
System.out.println("# docs Java: the system requirements page of each line on docs.spring.io (\"no page\" = 404)");
|
||||
System.out.printf("%-8s %-6s %-12s %-10s %-9s %-10s %-9s %-8s %s%n", "boot", "major", "docs Java",
|
||||
"framework", "tomcat", "jackson", "hibernate", "junit", "jooq");
|
||||
for (var e : latestPatchPerLine().entrySet()) {
|
||||
if (e.getKey().compareTo("2.7") < 0) {
|
||||
continue;
|
||||
}
|
||||
String v = e.getValue();
|
||||
Bom bom = Bom.read(central, v);
|
||||
String jackson = bom.properties().containsKey("jackson-bom.version")
|
||||
? bom.property("jackson-bom.version") : "-";
|
||||
System.out.printf("%-8s %-6d %-12s %-10s %-9s %-10s %-9s %-8s %s%n", v, classMajor(v),
|
||||
documentedJava(e.getKey(), v), bom.property("spring-framework.version"),
|
||||
bom.property("tomcat.version"), jackson, bom.property("hibernate.version"),
|
||||
bom.property("junit-jupiter.version"), bom.property("jooq.version"));
|
||||
}
|
||||
}
|
||||
|
||||
void calendar(LocalDate today) throws Exception {
|
||||
String url = "https://calendar.spring.io/releases?start=" + today + "&end=" + today.plusYears(1);
|
||||
System.out.println("# " + url);
|
||||
System.out.println("# open-source Spring Boot entries only (\"(Enterprise)\" patches left out)");
|
||||
for (JsonNode e : JsonMapper.shared().readTree(central.text(url))) {
|
||||
String title = e.path("title").asString();
|
||||
if (title.startsWith("Spring Boot ") && !title.contains("Enterprise")) {
|
||||
System.out.println(e.path("start").asString() + " " + title);
|
||||
}
|
||||
}
|
||||
var versions = central.gaVersions("org/springframework/boot", "spring-boot-dependencies");
|
||||
System.out.println("4.3 GA on Maven Central: " + versions.stream().anyMatch(v -> v.startsWith("4.3.")));
|
||||
System.out.println("4.3.x in api.spring.io generations: "
|
||||
+ Support.parse(central.text(API)).stream().anyMatch(s -> s.line().equals("4.3.x")));
|
||||
}
|
||||
|
||||
/** Every configuration property each module jar of a release declares: name to deprecation level. */
|
||||
private Map<String, JsonNode> propertiesOf(String version) throws Exception {
|
||||
Map<String, JsonNode> out = new TreeMap<>();
|
||||
for (String module : Bom.read(central, version).bootModules()) {
|
||||
Path jar;
|
||||
try {
|
||||
jar = central.file(BOOT + module + "/" + version + "/" + module + "-" + version + ".jar");
|
||||
} catch (IOException noJar) {
|
||||
continue;
|
||||
}
|
||||
try (var file = new JarFile(jar.toFile())) {
|
||||
var entry = file.getEntry("META-INF/spring-configuration-metadata.json");
|
||||
if (entry == null) {
|
||||
continue;
|
||||
}
|
||||
try (var in = file.getInputStream(entry)) {
|
||||
for (JsonNode p : JsonMapper.shared().readTree(in).path("properties")) {
|
||||
out.put(p.path("name").asString(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void properties(String from, String to) throws Exception {
|
||||
Map<String, JsonNode> before = propertiesOf(from);
|
||||
Map<String, JsonNode> after = propertiesOf(to);
|
||||
List<String> gone = new ArrayList<>();
|
||||
List<String> newlyDeprecated = new ArrayList<>();
|
||||
before.forEach((name, old) -> {
|
||||
JsonNode now = after.get(name);
|
||||
boolean wasDead = old.path("deprecation").path("level").asString("").equals("error");
|
||||
if (wasDead) {
|
||||
return;
|
||||
}
|
||||
if (now == null || now.path("deprecation").path("level").asString("").equals("error")) {
|
||||
gone.add(line(name, now));
|
||||
} else if (!old.has("deprecation") && now.has("deprecation")) {
|
||||
newlyDeprecated.add(line(name, now));
|
||||
}
|
||||
});
|
||||
long added = after.keySet().stream().filter(n -> !before.containsKey(n)).count();
|
||||
System.out.println("# configuration metadata of every org.springframework.boot jar in each BOM, " + from + " -> " + to);
|
||||
System.out.println(from + " declares " + before.size() + " properties, " + to + " declares " + after.size()
|
||||
+ " (" + added + " new names)");
|
||||
System.out.println();
|
||||
System.out.println("usable on " + from + ", unusable or absent on " + to + ": " + gone.size());
|
||||
gone.forEach(System.out::println);
|
||||
System.out.println();
|
||||
System.out.println("newly deprecated (still bound) on " + to + ": " + newlyDeprecated.size());
|
||||
newlyDeprecated.forEach(System.out::println);
|
||||
}
|
||||
|
||||
private static String line(String name, JsonNode now) {
|
||||
if (now == null) {
|
||||
return " " + name + " (not in metadata)";
|
||||
}
|
||||
String replacement = now.path("deprecation").path("replacement").asString("");
|
||||
return " " + name + (replacement.isEmpty() ? " (no replacement listed)" : " -> " + replacement);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ankurm.bootversions;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Pins the support-date table of the article to a saved copy of api.spring.io (2026-12-03). */
|
||||
class SupportTest {
|
||||
|
||||
private static final LocalDate DAY = LocalDate.parse("2026-12-03");
|
||||
|
||||
private static Support line(String name) throws IOException {
|
||||
try (var in = SupportTest.class.getResourceAsStream("/generations-2026-12-03.json")) {
|
||||
return Support.parse(new String(in.readAllBytes())).stream()
|
||||
.filter(s -> s.line().equals(name)).findFirst().orElseThrow();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void boot40LosesFreeSupportOn31December2026() throws IOException {
|
||||
Support s = line("4.0.x");
|
||||
assertEquals(LocalDate.parse("2026-12-31"), s.ossEnd());
|
||||
assertEquals(LocalDate.parse("2027-12-31"), s.commercialEnd());
|
||||
assertEquals(28, s.ossDaysLeft(DAY));
|
||||
assertEquals(Support.Status.OSS, s.statusOn(LocalDate.parse("2026-12-31")));
|
||||
assertEquals(Support.Status.COMMERCIAL_ONLY, s.statusOn(LocalDate.parse("2027-01-01")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void newerLines() throws IOException {
|
||||
assertEquals(LocalDate.parse("2027-07-31"), line("4.1.x").ossEnd());
|
||||
assertEquals(LocalDate.parse("2027-12-31"), line("4.2.x").ossEnd());
|
||||
assertEquals(LocalDate.parse("2028-12-31"), line("4.2.x").commercialEnd());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oldLines() throws IOException {
|
||||
assertEquals(Support.Status.COMMERCIAL_ONLY, line("3.5.x").statusOn(DAY));
|
||||
assertEquals(LocalDate.parse("2032-06-30"), line("3.5.x").commercialEnd());
|
||||
assertEquals(Support.Status.ENDED, line("3.3.x").statusOn(DAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void milestonesAreNotReleases() {
|
||||
assertEquals(List.of("4.1.3", "4.2.0"),
|
||||
Central.gaOnly(List.of("4.2.0", "4.3.0-M1", "4.1.3", "4.2.0-RC2", "4.2.1-SNAPSHOT")));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
{
|
||||
"_embedded" : {
|
||||
"generations" : [ {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/1.5.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "1.5.x",
|
||||
"initialReleaseDate" : "2017-01-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2019-08-31",
|
||||
"commercialSupportEndDate" : "2020-11-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "1.5.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.0.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.0.x",
|
||||
"initialReleaseDate" : "2018-03-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2019-03-31",
|
||||
"commercialSupportEndDate" : "2020-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.0.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.1.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.1.x",
|
||||
"initialReleaseDate" : "2018-10-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2019-10-31",
|
||||
"commercialSupportEndDate" : "2021-01-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.1.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.2.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.2.x",
|
||||
"initialReleaseDate" : "2019-10-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2020-10-31",
|
||||
"commercialSupportEndDate" : "2022-01-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.2.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.3.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.3.x",
|
||||
"initialReleaseDate" : "2020-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2021-05-31",
|
||||
"commercialSupportEndDate" : "2022-08-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.3.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.4.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.4.x",
|
||||
"initialReleaseDate" : "2020-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2021-11-30",
|
||||
"commercialSupportEndDate" : "2023-02-28",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.4.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.5.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.5.x",
|
||||
"initialReleaseDate" : "2021-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2022-05-31",
|
||||
"commercialSupportEndDate" : "2023-08-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.5.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.6.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.6.x",
|
||||
"initialReleaseDate" : "2021-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2022-11-30",
|
||||
"commercialSupportEndDate" : "2024-02-29",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.6.x" ]
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/2.7.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "2.7.x",
|
||||
"initialReleaseDate" : "2022-05-31",
|
||||
"support" : "extended",
|
||||
"ossSupportEndDate" : "2023-06-30",
|
||||
"commercialSupportEndDate" : "2029-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "2.7.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "2.7.37"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.0.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.0.x",
|
||||
"initialReleaseDate" : "2022-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2023-12-31",
|
||||
"commercialSupportEndDate" : "2024-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.0.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.0.20"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.1.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.1.x",
|
||||
"initialReleaseDate" : "2023-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2024-06-30",
|
||||
"commercialSupportEndDate" : "2025-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.1.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.1.21"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.2.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.2.x",
|
||||
"initialReleaseDate" : "2023-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2024-12-31",
|
||||
"commercialSupportEndDate" : "2025-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.2.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.2.19"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.3.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.3.x",
|
||||
"initialReleaseDate" : "2024-05-31",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2025-06-30",
|
||||
"commercialSupportEndDate" : "2026-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.3.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.3.20.1"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.4.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.4.x",
|
||||
"initialReleaseDate" : "2024-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2025-12-31",
|
||||
"commercialSupportEndDate" : "2026-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.4.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"enterprise" : "3.4.20"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/3.5.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "3.5.x",
|
||||
"initialReleaseDate" : "2025-05-31",
|
||||
"support" : "extended",
|
||||
"ossSupportEndDate" : "2026-06-30",
|
||||
"commercialSupportEndDate" : "2032-06-30",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "3.5.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "3.5.16",
|
||||
"enterprise" : "3.5.19"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/4.0.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "4.0.x",
|
||||
"initialReleaseDate" : "2025-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2026-12-31",
|
||||
"commercialSupportEndDate" : "2027-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "4.0.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "4.0.10",
|
||||
"enterprise" : "4.0.9.1"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/4.1.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "4.1.x",
|
||||
"initialReleaseDate" : "2026-06-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2027-07-31",
|
||||
"commercialSupportEndDate" : "2028-07-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "4.1.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "4.1.3",
|
||||
"enterprise" : "4.1.2.1"
|
||||
}
|
||||
}, {
|
||||
"_links" : {
|
||||
"self" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot/generations/4.2.x"
|
||||
},
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
},
|
||||
"name" : "4.2.x",
|
||||
"initialReleaseDate" : "2026-11-30",
|
||||
"support" : "default",
|
||||
"ossSupportEndDate" : "2027-12-31",
|
||||
"commercialSupportEndDate" : "2028-12-31",
|
||||
"linkedGenerations" : {
|
||||
"spring-boot" : [ "4.2.x" ]
|
||||
},
|
||||
"latestPatch" : {
|
||||
"oss" : "4.2.0"
|
||||
}
|
||||
} ]
|
||||
},
|
||||
"_links" : {
|
||||
"project" : {
|
||||
"href" : "https://api.spring.io/projects/spring-boot"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# boot4-migration
|
||||
|
||||
Companion module for the ankurm.com post
|
||||
[Spring Boot 3 to 4 Migration Guide (Updated for 4.1 and 4.2)](https://ankurm.com/spring-boot-3-to-4-migration-guide/).
|
||||
|
||||
One small service (Web MVC, Security, Actuator, JDBC + Flyway, AOP aspect, `RestClient.Builder`,
|
||||
a Jackson serializer, three tests) in two forms:
|
||||
|
||||
| Directory | What it is | Built by |
|
||||
|---|---|---|
|
||||
| `before/` | the service on Spring Boot 3.5.16 | never by a normal build; `scripts/run-all.sh` copies it to a scratch dir |
|
||||
| `after/` | the same service migrated to Spring Boot 4.1.2 | `cd after && mvn verify` |
|
||||
|
||||
`run-all.sh` builds `before/` as written, then bumps only the parent version and records what
|
||||
breaks at each step: the build error, the javac errors, the start-up failure report, the
|
||||
things that start fine but behave differently, and the test failures. Every file in `output/` is
|
||||
a real transcript from that script (JDK 25.0.5, Maven 3.9).
|
||||
|
||||
```bash
|
||||
export JAVA_HOME=/path/to/jdk-25
|
||||
./scripts/run-all.sh # 15-25 minutes on a shared 2-vCPU box; needs Maven Central
|
||||
```
|
||||
|
||||
| Output | Shows |
|
||||
|---|---|
|
||||
| `01-before-boot35.txt` | `before/` builds and runs on 3.5.16 (the baseline every other file is compared with) |
|
||||
| `02-bump-only-compile-errors.txt` | only the parent version changed: Maven POM error, then 12 javac errors |
|
||||
| `03-compiles-but-will-not-start.txt` | imports ported, starters not: compiles, fails at start-up (no `RestClient.Builder`) |
|
||||
| `04-starts-but-silently-wrong.txt` | starts, answers 200, but Flyway never ran, logs never rotate |
|
||||
| `05-properties-migrator.txt` | what `spring-boot-properties-migrator` does and does not report |
|
||||
| `06-after-boot41.txt` | `after/`: 8 tests pass, same endpoints, new health groups |
|
||||
| `07-jackson-property-order.txt` | bean property order on Jackson 2, Jackson 3, and `use-jackson2-defaults` |
|
||||
| `08-test-compile-errors.txt` | `@MockBean` and the old `@AutoConfigureMockMvc` package |
|
||||
| `09-test-runtime-failure.txt` | a plain `@Mock` field is `null`: compiles, fails at run time |
|
||||
| `10-security-dsl-compile-errors.txt` | the real javac message for the removed `authorizeHttpRequests()` chain |
|
||||
|
||||
Not covered: Gradle, Kotlin, native image, and any library that has not shipped a Boot 4 release.
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- THE "AFTER" APP: the same service migrated to Spring Boot 4.1.2. Builds on its own:
|
||||
mvn -B verify
|
||||
The "before" sources live in ../before and are never part of this build. -->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<groupId>com.ankurm</groupId>
|
||||
<artifactId>migration-demo</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<properties>
|
||||
<java.version>25</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- main code: one starter per technology -->
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webmvc</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-flyway</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aspectj</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-restclient</artifactId></dependency>
|
||||
<dependency><groupId>com.h2database</groupId><artifactId>h2</artifactId><scope>runtime</scope></dependency>
|
||||
<!-- test code: each starter has a -test companion -->
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webmvc-test</artifactId><scope>test</scope></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security-test</artifactId><scope>test</scope></dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DemoApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
/** Takes the auto-configured RestClient.Builder. RestClient itself lives in spring-web, so this always compiles. */
|
||||
@Component
|
||||
public class Gateway {
|
||||
private final RestClient client;
|
||||
|
||||
public Gateway(RestClient.Builder builder) {
|
||||
this.client = builder.baseUrl("http://localhost:9").build();
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return client.getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public record Greeting(long id, String title, Instant createdAt, String author) {
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class GreetingController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GreetingController.class);
|
||||
|
||||
private final GreetingService service;
|
||||
private final JdbcTemplate jdbc;
|
||||
private final Gateway gateway;
|
||||
|
||||
public GreetingController(GreetingService service, JdbcTemplate jdbc, Gateway gateway) {
|
||||
this.service = service;
|
||||
this.jdbc = jdbc;
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
@GetMapping("/greetings/{id}")
|
||||
public Greeting greeting(@PathVariable long id) {
|
||||
log.info("served greeting {} ........................................", id);
|
||||
return new Greeting(id, service.title(id), Instant.parse("2026-01-02T03:04:05Z"), "ankur");
|
||||
}
|
||||
|
||||
/** Serialised by Jackson's default record handling (no custom serializer). */
|
||||
@GetMapping("/summary")
|
||||
public Summary summary() {
|
||||
Summary s = new Summary();
|
||||
s.setId(1);
|
||||
s.setTitle("Hello");
|
||||
s.setCreatedAt(Instant.parse("2026-01-02T03:04:05Z"));
|
||||
s.setAuthor("ankur");
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Reads the table that the Flyway migration V1 creates. */
|
||||
@GetMapping("/greetings/count")
|
||||
public Map<String, Object> count() {
|
||||
Integer n = jdbc.queryForObject("select count(*) from greeting", Integer.class);
|
||||
return Map.of("rows", n);
|
||||
}
|
||||
|
||||
/** How many times the @Aspect has intercepted GreetingService. */
|
||||
@GetMapping("/aspect")
|
||||
public Map<String, Object> aspect() {
|
||||
return Map.of("interceptions", TimingAspect.COUNT.get());
|
||||
}
|
||||
|
||||
@GetMapping("/gateway")
|
||||
public Map<String, Object> gateway() {
|
||||
return Map.of("client", gateway.describe());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class GreetingService {
|
||||
public String title(long id) {
|
||||
return "Hello #" + id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.boot.jackson.JacksonComponent;
|
||||
import tools.jackson.core.JacksonException;
|
||||
import tools.jackson.core.JsonGenerator;
|
||||
import tools.jackson.databind.SerializationContext;
|
||||
import tools.jackson.databind.ser.std.StdSerializer;
|
||||
|
||||
/** Boot 4: Jackson 3 (tools.jackson), @JacksonComponent, and no checked IOException. */
|
||||
@JacksonComponent
|
||||
public class JsonConfig extends StdSerializer<Greeting> {
|
||||
|
||||
public JsonConfig() {
|
||||
super(Greeting.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Greeting g, JsonGenerator gen, SerializationContext ctxt) throws JacksonException {
|
||||
gen.writeStartObject();
|
||||
gen.writeNumberProperty("id", g.id());
|
||||
gen.writeStringProperty("title", g.title());
|
||||
gen.writeStringProperty("createdAt", g.createdAt().toString());
|
||||
gen.writeStringProperty("author", g.author());
|
||||
gen.writeEndObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.boot.security.autoconfigure.web.servlet.SecurityFilterProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
@Order(SecurityFilterProperties.BASIC_AUTH_ORDER)
|
||||
SecurityFilterChain chain(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(a -> a
|
||||
.requestMatchers("/actuator/health/**", "/greetings/**", "/aspect", "/gateway").permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.httpBasic(Customizer.withDefaults());
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A plain bean (not a record) whose properties are deliberately NOT in alphabetical order.
|
||||
* Jackson 2 wrote them in declaration order; Jackson 3 sorts bean properties alphabetically by default.
|
||||
* (Records are unaffected: creator parameters are always written first, in constructor order.)
|
||||
*/
|
||||
public class Summary {
|
||||
private long id;
|
||||
private String title;
|
||||
private Instant createdAt;
|
||||
private String author;
|
||||
|
||||
public long getId() { return id; }
|
||||
public void setId(long id) { this.id = id; }
|
||||
public String getTitle() { return title; }
|
||||
public void setTitle(String title) { this.title = title; }
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
public String getAuthor() { return author; }
|
||||
public void setAuthor(String author) { this.author = author; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/** Needs AspectJ weaving support on the classpath: spring-boot-starter-aop in Boot 3. */
|
||||
@Aspect
|
||||
@Component
|
||||
public class TimingAspect {
|
||||
static final AtomicInteger COUNT = new AtomicInteger();
|
||||
|
||||
@Around("execution(* com.ankurm.migration.GreetingService.*(..))")
|
||||
public Object count(ProceedingJoinPoint pjp) throws Throwable {
|
||||
COUNT.incrementAndGet();
|
||||
return pjp.proceed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
spring.datasource.url=jdbc:h2:mem:demo;DB_CLOSE_DELAY=-1
|
||||
management.endpoints.web.exposure.include=health,metrics
|
||||
management.endpoint.health.show-details=always
|
||||
logging.file.name=${LOG_DIR:target/logs}/app.log
|
||||
# Boot 4.1 removed the old logging.file.* rolling keys; these are the replacements
|
||||
logging.logback.rollingpolicy.max-file-size=2KB
|
||||
logging.logback.rollingpolicy.max-history=50
|
||||
@@ -0,0 +1,2 @@
|
||||
create table greeting (id bigint primary key, title varchar(100) not null);
|
||||
insert into greeting values (1, 'first'), (2, 'second'), (3, 'third');
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
/** Prints the status of a Basic-authenticated POST without a CSRF token (to compare 3.5 with 4.1). */
|
||||
@SpringBootTest(properties = "spring.security.user.password=pw")
|
||||
@AutoConfigureMockMvc
|
||||
class CsrfProbeTest {
|
||||
|
||||
@Autowired MockMvc mvc;
|
||||
|
||||
@Test
|
||||
void postWithoutCsrfToken() throws Exception {
|
||||
int status = mvc.perform(post("/anything").with(httpBasic("user", "pw"))).andReturn().getResponse().getStatus();
|
||||
System.out.println("CSRFPROBE status=" + status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
|
||||
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
class GreetingControllerTest {
|
||||
|
||||
@Autowired MockMvc mvc;
|
||||
@MockitoBean GreetingService service;
|
||||
|
||||
@Test
|
||||
void greetingUsesService() throws Exception {
|
||||
given(service.title(7)).willReturn("mocked");
|
||||
mvc.perform(get("/greetings/7")).andExpect(status().isOk()).andExpect(jsonPath("$.title").value("mocked"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/** Boot 4 fix: Mockito's own extension initialises @Mock fields. */
|
||||
@SpringBootTest
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MockFieldTest {
|
||||
|
||||
@Mock Runnable task;
|
||||
|
||||
@Test
|
||||
void mockFieldIsInitialised() {
|
||||
assertNotNull(task, "@Mock field was never initialised");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
/** Pins the runtime behaviour the "breaks at runtime" checklist is about, so a regression fails the build. */
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
class RuntimeFactsTest {
|
||||
|
||||
@Autowired MockMvc mvc;
|
||||
@Autowired JdbcTemplate jdbc;
|
||||
|
||||
@Test
|
||||
void flywayMigrationRan() {
|
||||
assertThat(jdbc.queryForObject("select count(*) from greeting", Integer.class)).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aspectIntercepts() throws Exception {
|
||||
mvc.perform(get("/greetings/1")).andExpect(status().isOk());
|
||||
assertThat(TimingAspect.COUNT.get()).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void restClientBuilderIsAutoConfigured() throws Exception {
|
||||
mvc.perform(get("/gateway")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
void metricsEndpointExists() throws Exception {
|
||||
mvc.perform(get("/actuator/metrics").with(user("u")))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
void serializerIsTheJacksonComponent() throws Exception {
|
||||
mvc.perform(get("/greetings/2")).andExpect(content().json("{\"id\":2,\"title\":\"Hello #2\"}"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- THE "BEFORE" APP: a Spring Boot 3.5.16 service written the way most 3.x services are.
|
||||
It is NOT part of any build in this repository; scripts/run-all.sh copies it to a scratch
|
||||
directory and builds it there, first as-is and then with the parent bumped to 4.1.2. -->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.5.16</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<groupId>com.ankurm</groupId>
|
||||
<artifactId>migration-demo</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<properties>
|
||||
<java.version>25</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId></dependency>
|
||||
<dependency><groupId>com.h2database</groupId><artifactId>h2</artifactId><scope>runtime</scope></dependency>
|
||||
<!-- Boot 3: Flyway needs only the library, Boot's auto-configuration was in the big autoconfigure jar -->
|
||||
<dependency><groupId>org.flywaydb</groupId><artifactId>flyway-core</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
|
||||
<dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-test</artifactId><scope>test</scope></dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DemoApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
/** Takes the auto-configured RestClient.Builder. RestClient itself lives in spring-web, so this always compiles. */
|
||||
@Component
|
||||
public class Gateway {
|
||||
private final RestClient client;
|
||||
|
||||
public Gateway(RestClient.Builder builder) {
|
||||
this.client = builder.baseUrl("http://localhost:9").build();
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return client.getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public record Greeting(long id, String title, Instant createdAt, String author) {
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class GreetingController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GreetingController.class);
|
||||
|
||||
private final GreetingService service;
|
||||
private final JdbcTemplate jdbc;
|
||||
private final Gateway gateway;
|
||||
|
||||
public GreetingController(GreetingService service, JdbcTemplate jdbc, Gateway gateway) {
|
||||
this.service = service;
|
||||
this.jdbc = jdbc;
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
@GetMapping("/greetings/{id}")
|
||||
public Greeting greeting(@PathVariable long id) {
|
||||
log.info("served greeting {} ........................................", id);
|
||||
return new Greeting(id, service.title(id), Instant.parse("2026-01-02T03:04:05Z"), "ankur");
|
||||
}
|
||||
|
||||
/** Serialised by Jackson's default record handling (no custom serializer). */
|
||||
@GetMapping("/summary")
|
||||
public Summary summary() {
|
||||
Summary s = new Summary();
|
||||
s.setId(1);
|
||||
s.setTitle("Hello");
|
||||
s.setCreatedAt(Instant.parse("2026-01-02T03:04:05Z"));
|
||||
s.setAuthor("ankur");
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Reads the table that the Flyway migration V1 creates. */
|
||||
@GetMapping("/greetings/count")
|
||||
public Map<String, Object> count() {
|
||||
Integer n = jdbc.queryForObject("select count(*) from greeting", Integer.class);
|
||||
return Map.of("rows", n);
|
||||
}
|
||||
|
||||
/** How many times the @Aspect has intercepted GreetingService. */
|
||||
@GetMapping("/aspect")
|
||||
public Map<String, Object> aspect() {
|
||||
return Map.of("interceptions", TimingAspect.COUNT.get());
|
||||
}
|
||||
|
||||
@GetMapping("/gateway")
|
||||
public Map<String, Object> gateway() {
|
||||
return Map.of("client", gateway.describe());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class GreetingService {
|
||||
public String title(long id) {
|
||||
return "Hello #" + id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import org.springframework.boot.jackson.JsonComponent;
|
||||
|
||||
/** Boot 3 idiom: a Jackson 2 serializer registered through Boot's @JsonComponent. */
|
||||
@JsonComponent
|
||||
public class JsonConfig extends JsonSerializer<Greeting> {
|
||||
@Override
|
||||
public void serialize(Greeting g, JsonGenerator gen, SerializerProvider sp) throws IOException {
|
||||
gen.writeStartObject();
|
||||
gen.writeNumberField("id", g.id());
|
||||
gen.writeStringField("title", g.title());
|
||||
gen.writeStringField("createdAt", g.createdAt().toString());
|
||||
gen.writeStringField("author", g.author());
|
||||
gen.writeEndObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
SecurityFilterChain chain(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests()
|
||||
.requestMatchers("/actuator/health/**", "/greetings/**", "/aspect", "/gateway").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.httpBasic();
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A plain bean (not a record) whose properties are deliberately NOT in alphabetical order.
|
||||
* Jackson 2 wrote them in declaration order; Jackson 3 sorts bean properties alphabetically by default.
|
||||
* (Records are unaffected: creator parameters are always written first, in constructor order.)
|
||||
*/
|
||||
public class Summary {
|
||||
private long id;
|
||||
private String title;
|
||||
private Instant createdAt;
|
||||
private String author;
|
||||
|
||||
public long getId() { return id; }
|
||||
public void setId(long id) { this.id = id; }
|
||||
public String getTitle() { return title; }
|
||||
public void setTitle(String title) { this.title = title; }
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
public String getAuthor() { return author; }
|
||||
public void setAuthor(String author) { this.author = author; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/** Needs AspectJ weaving support on the classpath: spring-boot-starter-aop in Boot 3. */
|
||||
@Aspect
|
||||
@Component
|
||||
public class TimingAspect {
|
||||
static final AtomicInteger COUNT = new AtomicInteger();
|
||||
|
||||
@Around("execution(* com.ankurm.migration.GreetingService.*(..))")
|
||||
public Object count(ProceedingJoinPoint pjp) throws Throwable {
|
||||
COUNT.incrementAndGet();
|
||||
return pjp.proceed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
spring.datasource.url=jdbc:h2:mem:demo;DB_CLOSE_DELAY=-1
|
||||
management.endpoints.web.exposure.include=health,metrics
|
||||
management.endpoint.health.show-details=always
|
||||
# Boot 3 logging properties that were deprecated for years (replaced by logging.logback.rollingpolicy.*)
|
||||
logging.file.name=${LOG_DIR:target/logs}/app.log
|
||||
logging.file.max-size=2KB
|
||||
logging.file.max-history=50
|
||||
@@ -0,0 +1,2 @@
|
||||
create table greeting (id bigint primary key, title varchar(100) not null);
|
||||
insert into greeting values (1, 'first'), (2, 'second'), (3, 'third');
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
/** Prints the status of a Basic-authenticated POST without a CSRF token (to compare 3.5 with 4.1). */
|
||||
@SpringBootTest(properties = "spring.security.user.password=pw")
|
||||
@AutoConfigureMockMvc
|
||||
class CsrfProbeTest {
|
||||
|
||||
@Autowired MockMvc mvc;
|
||||
|
||||
@Test
|
||||
void postWithoutCsrfToken() throws Exception {
|
||||
int status = mvc.perform(post("/anything").with(httpBasic("user", "pw"))).andReturn().getResponse().getStatus();
|
||||
System.out.println("CSRFPROBE status=" + status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
class GreetingControllerTest {
|
||||
|
||||
@Autowired MockMvc mvc;
|
||||
@MockBean GreetingService service;
|
||||
|
||||
@Test
|
||||
void greetingUsesService() throws Exception {
|
||||
given(service.title(7)).willReturn("mocked");
|
||||
mvc.perform(get("/greetings/7")).andExpect(status().isOk()).andExpect(jsonPath("$.title").value("mocked"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ankurm.migration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* A plain Mockito @Mock field inside a @SpringBootTest, with no MockitoExtension.
|
||||
* Boot 3 initialised it through MockitoTestExecutionListener; Boot 4 removed that listener.
|
||||
*/
|
||||
@SpringBootTest
|
||||
class MockFieldTest {
|
||||
|
||||
@Mock Runnable task;
|
||||
|
||||
@Test
|
||||
void mockFieldIsInitialised() {
|
||||
assertNotNull(task, "@Mock field was never initialised");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
$ mvn package # before/ as written: Boot 3.5.16, JDK 25.0.5
|
||||
CSRFPROBE status=403
|
||||
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
|
||||
[INFO] BUILD SUCCESS
|
||||
|
||||
$ java -jar migration-demo-1.0.0.jar # Boot 3.5.16
|
||||
GET /summary
|
||||
{"id":1,"title":"Hello","createdAt":"2026-01-02T03:04:05Z","author":"ankur"} -> HTTP 200
|
||||
GET /greetings/1
|
||||
{"id":1,"title":"Hello #1","createdAt":"2026-01-02T03:04:05Z","author":"ankur"} -> HTTP 200
|
||||
GET /greetings/count
|
||||
{"rows":3} -> HTTP 200
|
||||
GET /aspect
|
||||
{"interceptions":1} -> HTTP 200
|
||||
GET /gateway
|
||||
{"client":"DefaultRestClient"} -> HTTP 200
|
||||
GET /actuator/metrics (first 60 chars)
|
||||
{"names":["application.ready.time","application.started.time
|
||||
GET /actuator/health (groups and status only)
|
||||
groups=None status=UP components=['db', 'diskSpace', 'ping', 'ssl']
|
||||
GET /actuator/health/liveness
|
||||
-> HTTP 404
|
||||
after 40 more requests, log directory holds: 1 app.log; 5 app.log.<date>.<n>.gz; (app.log is 342 bytes; limit set is logging.file.max-size=2KB or its 4.1 replacement)
|
||||
@@ -0,0 +1,35 @@
|
||||
$ mvn -DskipTests package # same sources, same pom, only <parent><version> 3.5.16 -> 4.1.2
|
||||
[ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-aop:jar is missing. @ line 25, column 17
|
||||
[ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-aop:jar is missing. @ line 25, column 17
|
||||
|
||||
# spring-boot-starter-aop has no managed version any more. Rename it to spring-boot-starter-aspectj and try again:
|
||||
$ mvn compile
|
||||
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.15.0:compile (default-compile) on project migration-demo: Fatal error compiling: Cannot load from object array because "this.hashes" is null
|
||||
[INFO] BUILD FAILURE
|
||||
# Maven's compiler plugin 3.15.0 on JDK 25 crashed inside javac instead of listing the errors, so ask javac directly:
|
||||
$ javac -cp $(mvn dependency:build-classpath) src/main/java/**/*.java
|
||||
SecurityConfig.java:3: error: package org.springframework.boot.autoconfigure.security does not exist
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
JsonConfig.java:5: error: package com.fasterxml.jackson.core does not exist
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
JsonConfig.java:6: error: package com.fasterxml.jackson.databind does not exist
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
JsonConfig.java:7: error: package com.fasterxml.jackson.databind does not exist
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
JsonConfig.java:8: error: cannot find symbol
|
||||
import org.springframework.boot.jackson.JsonComponent;
|
||||
JsonConfig.java:12: error: cannot find symbol
|
||||
public class JsonConfig extends JsonSerializer<Greeting> {
|
||||
JsonConfig.java:11: error: cannot find symbol
|
||||
@JsonComponent
|
||||
JsonConfig.java:14: error: cannot find symbol
|
||||
public void serialize(Greeting g, JsonGenerator gen, SerializerProvider sp) throws IOException {
|
||||
JsonConfig.java:14: error: cannot find symbol
|
||||
public void serialize(Greeting g, JsonGenerator gen, SerializerProvider sp) throws IOException {
|
||||
SecurityConfig.java:14: error: cannot find symbol
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
SecurityConfig.java:16: error: method authorizeHttpRequests in class HttpSecurity cannot be applied to given types;
|
||||
http.authorizeHttpRequests()
|
||||
JsonConfig.java:13: error: method does not override or implement a method from a supertype
|
||||
@Override
|
||||
javac error count: 12
|
||||
@@ -0,0 +1,11 @@
|
||||
$ # s2 = before/ + Boot 4.1.2 + aop->aspectj + JsonConfig and SecurityConfig ported (imports only); every other dependency untouched
|
||||
$ mvn -DskipTests package
|
||||
[INFO] BUILD SUCCESS
|
||||
|
||||
$ java -jar migration-demo-1.0.0.jar
|
||||
APPLICATION DID NOT START. The failure report:
|
||||
APPLICATION FAILED TO START
|
||||
***************************
|
||||
Description:
|
||||
Parameter 0 of constructor in com.ankurm.migration.Gateway required a bean of type 'org.springframework.web.client.RestClient$Builder' that could not be found.
|
||||
Action:
|
||||
@@ -0,0 +1,25 @@
|
||||
$ # s3 = s2 + spring-boot-starter-restclient (the only thing the start-up failure asked for). Flyway, properties and the rest still Boot 3 style.
|
||||
$ mvn -DskipTests package
|
||||
[INFO] BUILD SUCCESS
|
||||
|
||||
$ java -jar migration-demo-1.0.0.jar
|
||||
GET /summary
|
||||
{"author":"ankur","createdAt":"2026-01-02T03:04:05Z","id":1,"title":"Hello"} -> HTTP 200
|
||||
GET /greetings/1
|
||||
{"id":1,"title":"Hello #1","createdAt":"2026-01-02T03:04:05Z","author":"ankur"} -> HTTP 200
|
||||
GET /greetings/count
|
||||
{"timestamp":"2026-10-29T05:55:01.660Z","status":500,"error":"Internal Server Error","path":"/greetings/count"} -> HTTP 500
|
||||
GET /aspect
|
||||
{"interceptions":1} -> HTTP 200
|
||||
GET /gateway
|
||||
{"client":"DefaultRestClient"} -> HTTP 200
|
||||
GET /actuator/metrics (first 60 chars)
|
||||
{"names":["application.ready.time","application.started.time
|
||||
GET /actuator/health (groups and status only)
|
||||
groups=['liveness', 'readiness'] status=UP components=['db', 'diskSpace', 'livenessState', 'ping', 'readinessState', 'ssl']
|
||||
GET /actuator/health/liveness
|
||||
-> HTTP 200
|
||||
root cause of that 500 in the application log:
|
||||
Table "GREETING" not found
|
||||
Flyway log lines at start-up: 0
|
||||
after 40 more requests, log directory holds: 1 app.log; (app.log is 54188 bytes; limit set is logging.file.max-size=2KB or its 4.1 replacement)
|
||||
@@ -0,0 +1,13 @@
|
||||
$ # s6 = s3 + spring-boot-properties-migrator (runtime scope)
|
||||
[INFO] BUILD SUCCESS
|
||||
app started
|
||||
$ grep -iE 'propert|logging.file|migrat' run.log # what the migrator printed at start-up
|
||||
WARN 6819 --- [ main] o.s.b.c.p.m.PropertiesMigrationListener :
|
||||
The use of configuration keys that have been renamed was found in the environment:
|
||||
Property source 'Config resource 'class path resource [application.properties]' via location 'optional:classpath:/'':
|
||||
Key: logging.file.max-history
|
||||
Replacement: logging.logback.rollingpolicy.max-history
|
||||
Key: logging.file.max-size
|
||||
Replacement: logging.logback.rollingpolicy.max-file-size
|
||||
Each configuration key has been temporarily mapped to its replacement for your convenience. To silence this warning, please update your configuration to use the new keys.
|
||||
(lines matching: 3)
|
||||
@@ -0,0 +1,23 @@
|
||||
$ mvn verify # after/ : Boot 4.1.2, one starter per technology, -test companions, Jackson 3, new packages
|
||||
CSRFPROBE status=403
|
||||
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
|
||||
[INFO] BUILD SUCCESS
|
||||
|
||||
$ java -jar migration-demo-1.0.0.jar
|
||||
GET /summary
|
||||
{"author":"ankur","createdAt":"2026-01-02T03:04:05Z","id":1,"title":"Hello"} -> HTTP 200
|
||||
GET /greetings/1
|
||||
{"id":1,"title":"Hello #1","createdAt":"2026-01-02T03:04:05Z","author":"ankur"} -> HTTP 200
|
||||
GET /greetings/count
|
||||
{"rows":3} -> HTTP 200
|
||||
GET /aspect
|
||||
{"interceptions":1} -> HTTP 200
|
||||
GET /gateway
|
||||
{"client":"DefaultRestClient"} -> HTTP 200
|
||||
GET /actuator/metrics (first 60 chars)
|
||||
{"names":["application.ready.time","application.started.time
|
||||
GET /actuator/health (groups and status only)
|
||||
groups=['liveness', 'readiness'] status=UP components=['db', 'diskSpace', 'livenessState', 'ping', 'readinessState', 'ssl']
|
||||
GET /actuator/health/liveness
|
||||
-> HTTP 200
|
||||
after 40 more requests, log directory holds: 1 app.log; 5 app.log.<date>.<n>.gz; (app.log is 513 bytes; limit set is logging.file.max-size=2KB or its 4.1 replacement)
|
||||
@@ -0,0 +1,4 @@
|
||||
# GET /summary on the same bean (id, title, createdAt, author declared in that order)
|
||||
Boot 3.5.16 (Jackson 2): {"id":1,"title":"Hello","createdAt":"2026-01-02T03:04:05Z","author":"ankur"} -> HTTP 200
|
||||
Boot 4.1.2 (Jackson 3, defaults): {"author":"ankur","createdAt":"2026-01-02T03:04:05Z","id":1,"title":"Hello"} -> HTTP 200
|
||||
Boot 4.1.2 + spring.jackson.use-jackson2-defaults: {"id":1,"title":"Hello","createdAt":"2026-01-02T03:04:05Z","author":"ankur"} -> HTTP 200
|
||||
@@ -0,0 +1,6 @@
|
||||
$ mvn test-compile # after/ pom and main code, but the Boot 3 GreetingControllerTest (@MockBean, old @AutoConfigureMockMvc package)
|
||||
t1/src/test/java/com/ankurm/migration/GreetingControllerTest.java:[10,63] package org.springframework.boot.test.autoconfigure.web.servlet does not exist
|
||||
t1/src/test/java/com/ankurm/migration/GreetingControllerTest.java:[12,50] package org.springframework.boot.test.mock.mockito does not exist
|
||||
t1/src/test/java/com/ankurm/migration/GreetingControllerTest.java:[16,2] cannot find symbol
|
||||
t1/src/test/java/com/ankurm/migration/GreetingControllerTest.java:[20,6] cannot find symbol
|
||||
[INFO] BUILD FAILURE
|
||||
@@ -0,0 +1,5 @@
|
||||
$ mvn test # after/ pom and main code + the Boot 3 MockFieldTest unchanged (compiles) and CsrfProbeTest (one import fixed)
|
||||
CSRFPROBE status=403
|
||||
[ERROR] MockFieldTest.mockFieldIsInitialised:20 @Mock field was never initialised ==> expected: not <null>
|
||||
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
|
||||
[INFO] BUILD FAILURE
|
||||
@@ -0,0 +1,8 @@
|
||||
$ javac SecurityConfig.java # Boot 3 file, import repointed to the 4.1.2 package; the old method-chaining DSL left as it was
|
||||
SecurityConfig.java:16: error: method authorizeHttpRequests in class HttpSecurity cannot be applied to given types;
|
||||
http.authorizeHttpRequests()
|
||||
^
|
||||
required: Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry>
|
||||
found: no arguments
|
||||
reason: actual and formal argument lists differ in length
|
||||
1 error
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates every file in output/. Needs JDK 25 (JAVA_HOME), Maven 3.9 and network access to Maven Central.
|
||||
# The "before" app (Boot 3.5.16) is never built in place: each stage is copied to a scratch directory.
|
||||
# Takes 15-25 minutes on a shared 2-vCPU box (each stage is a real Maven build and most start the app).
|
||||
set -u
|
||||
HERE=$(cd "$(dirname "$0")/.." && pwd); OUT=$HERE/output; W=${WORK:-/tmp/b4m-work}
|
||||
MVN=${MVN:-mvn}; PORT=${PORT:-18090}; URL=http://localhost:$PORT
|
||||
BOOT_OLD=3.5.16; BOOT_NEW=4.1.2
|
||||
mkdir -p "$OUT"; rm -rf "$W"; mkdir -p "$W"
|
||||
|
||||
mv_() { local d=$1; shift; (cd "$d" && $MVN -B -T1 "$@" 2>&1 | grep -vE 'JAVA_TOOL_OPTIONS|^WARNING: |Download(ing|ed)' | sed "s#$W/##g"); }
|
||||
stage() { rm -rf "$W/$1"; mkdir -p "$W/$1"; cp -r "$HERE/$2/pom.xml" "$HERE/$2/src" "$W/$1/"; }
|
||||
bump() { sed -i "s#<version>$BOOT_OLD</version>#<version>$BOOT_NEW</version>#" "$W/$1/pom.xml"; }
|
||||
AFTER_MAIN=$HERE/after/src/main/java/com/ankurm/migration
|
||||
BEFORE_TEST=$HERE/before/src/test/java/com/ankurm/migration
|
||||
|
||||
# start <label> <jar> [extra args]; leaves the app running on $PORT, pid in $W/pid
|
||||
start() {
|
||||
local label=$1 jar=$2; shift 2
|
||||
rm -rf "$W/logs-$label"
|
||||
LOG_DIR="$W/logs-$label" java -jar "$jar" --server.port=$PORT --spring.security.user.password=pw "$@" > "$W/run-$label.log" 2>&1 &
|
||||
echo $! > "$W/pid"
|
||||
for _ in $(seq 1 240); do curl -s -o /dev/null $URL/actuator/health && return 0; kill -0 "$(cat "$W/pid")" 2>/dev/null || return 1; sleep 1; done
|
||||
return 1
|
||||
}
|
||||
stop() { kill "$(cat "$W/pid")" 2>/dev/null; wait "$(cat "$W/pid")" 2>/dev/null; sleep 1; }
|
||||
g() { echo "GET $1"; curl -s -u user:pw -w ' -> HTTP %{http_code}\n' "$URL$1" | cut -c1-200; }
|
||||
# probe <label> <jar> [extra args] -> prints what the running app does
|
||||
probe() {
|
||||
local label=$1; shift
|
||||
if ! start "$label" "$@"; then
|
||||
echo "APPLICATION DID NOT START. The failure report:"; sed -n '/APPLICATION FAILED TO START/,/^Action:/p' "$W/run-$label.log" | grep -v '^$' | head -12
|
||||
stop; return
|
||||
fi
|
||||
g /summary; g /greetings/1; g /greetings/count; g /aspect; g /gateway
|
||||
echo "GET /actuator/metrics (first 60 chars)"; curl -s -u user:pw -w ' -> HTTP %{http_code}\n' $URL/actuator/metrics | cut -c1-60
|
||||
echo "GET /actuator/health (groups and status only)"
|
||||
curl -s $URL/actuator/health | python3 -c 'import sys,json; d=json.load(sys.stdin); print(" groups=%s status=%s components=%s" % (d.get("groups"), d["status"], sorted(d.get("components",{}))))'
|
||||
echo "GET /actuator/health/liveness"; curl -s -o /dev/null -w ' -> HTTP %{http_code}\n' $URL/actuator/health/liveness
|
||||
if curl -s -u user:pw $URL/greetings/count | grep -q '"status":500'; then echo "root cause of that 500 in the application log:"; grep -oE 'Table "[A-Z]+" not found' "$W/run-$label.log" | sort -u | sed 's/^/ /'; echo "Flyway log lines at start-up: $(grep -c 'org.flywaydb' "$W/run-$label.log")"; fi
|
||||
for _ in $(seq 1 40); do curl -s $URL/greetings/1 > /dev/null; done
|
||||
echo "after 40 more requests, log directory holds: $(ls "$W/logs-$label" | sed 's/\.[0-9-]*\.[0-9]*\.gz/.<date>.<n>.gz/' | sort | uniq -c | tr -s ' ' | tr '\n' ';') (app.log is $(stat -c %s "$W/logs-$label/app.log") bytes; limit set is logging.file.max-size=2KB or its 4.1 replacement)"
|
||||
stop
|
||||
}
|
||||
hdr() { echo "\$ $*"; }
|
||||
|
||||
# ---------------------------------------------------------------- 01 baseline on Boot 3.5.16
|
||||
stage s0 before
|
||||
{ hdr "mvn package # before/ as written: Boot $BOOT_OLD, JDK $(java -version 2>&1 | grep -v JAVA_TOOL | head -1 | cut -d'"' -f2)"
|
||||
mv_ "$W/s0" package > "$W/s0.log"; grep -E 'Tests run:|CSRFPROBE|BUILD' "$W/s0.log" | grep -v 'Time elapsed'
|
||||
echo; hdr "java -jar migration-demo-1.0.0.jar # Boot $BOOT_OLD"
|
||||
probe boot35 "$W/s0/target/migration-demo-1.0.0.jar"; } > "$OUT/01-before-boot35.txt"
|
||||
cp "$OUT/01-before-boot35.txt" "$W/probe-boot35.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 02 change nothing but the parent version
|
||||
stage s1 before; bump s1
|
||||
{ hdr "mvn -DskipTests package # same sources, same pom, only <parent><version> $BOOT_OLD -> $BOOT_NEW"
|
||||
mv_ "$W/s1" -DskipTests package | grep -E 'ERROR.*(dependency|missing)|BUILD' | sort -u
|
||||
echo; echo "# spring-boot-starter-aop has no managed version any more. Rename it to spring-boot-starter-aspectj and try again:"
|
||||
sed -i 's/spring-boot-starter-aop/spring-boot-starter-aspectj/' "$W/s1/pom.xml"
|
||||
hdr "mvn compile"
|
||||
mv_ "$W/s1" compile > "$W/s1.log"
|
||||
grep -E 'BUILD|Fatal error compiling' "$W/s1.log" | sed 's/ -> \[Help 1\]//' | sort -u | cut -c1-230
|
||||
echo "# Maven's compiler plugin 3.15.0 on JDK 25 crashed inside javac instead of listing the errors, so ask javac directly:"
|
||||
hdr "javac -cp \$(mvn dependency:build-classpath) src/main/java/**/*.java"
|
||||
(cd "$W/s1" && $MVN -B -q dependency:build-classpath -Dmdep.outputFile="$W/cp.txt" > /dev/null 2>&1; mkdir -p "$W/jc"
|
||||
javac -d "$W/jc" -cp "$(cat "$W/cp.txt")" $(find src/main -name '*.java') 2>&1 | grep -v JAVA_TOOL > "$W/s1.javac")
|
||||
grep -A1 -E 'error:' "$W/s1.javac" | grep -v '^--' | sed 's#^src/main/java/com/ankurm/migration/##'
|
||||
echo "javac error count: $(grep -c 'error:' "$W/s1.javac")"; } > "$OUT/02-bump-only-compile-errors.txt"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 03 imports fixed, starters untouched -> startup failure
|
||||
stage s2 before; bump s2; sed -i 's/spring-boot-starter-aop/spring-boot-starter-aspectj/' "$W/s2/pom.xml"
|
||||
rm -rf "$W/s2/src/test"; cp "$AFTER_MAIN"/JsonConfig.java "$AFTER_MAIN"/SecurityConfig.java "$W/s2/src/main/java/com/ankurm/migration/"
|
||||
{ hdr "# s2 = before/ + Boot $BOOT_NEW + aop->aspectj + JsonConfig and SecurityConfig ported (imports only); every other dependency untouched"
|
||||
hdr "mvn -DskipTests package"
|
||||
mv_ "$W/s2" -DskipTests package | grep -E 'ERROR|BUILD'
|
||||
echo; hdr "java -jar migration-demo-1.0.0.jar"
|
||||
probe starters-missing "$W/s2/target/migration-demo-1.0.0.jar"; } > "$OUT/03-compiles-but-will-not-start.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 04 start-up fixed -> the silent ones
|
||||
stage s3 before; bump s3; sed -i 's/spring-boot-starter-aop/spring-boot-starter-aspectj/' "$W/s3/pom.xml"
|
||||
rm -rf "$W/s3/src/test"; cp "$AFTER_MAIN"/JsonConfig.java "$AFTER_MAIN"/SecurityConfig.java "$W/s3/src/main/java/com/ankurm/migration/"
|
||||
sed -i 's#<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc#<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-restclient</artifactId></dependency>\n <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc#' "$W/s3/pom.xml"
|
||||
{ hdr "# s3 = s2 + spring-boot-starter-restclient (the only thing the start-up failure asked for). Flyway, properties and the rest still Boot 3 style."
|
||||
hdr "mvn -DskipTests package"
|
||||
mv_ "$W/s3" -DskipTests package | grep -E 'ERROR|BUILD'
|
||||
echo; hdr "java -jar migration-demo-1.0.0.jar"
|
||||
probe silent "$W/s3/target/migration-demo-1.0.0.jar"; } > "$OUT/04-starts-but-silently-wrong.txt"
|
||||
cp "$OUT/04-starts-but-silently-wrong.txt" "$W/probe-silent.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 05 properties migrator on the silent build
|
||||
stage s6 before; bump s6; sed -i 's/spring-boot-starter-aop/spring-boot-starter-aspectj/' "$W/s6/pom.xml"
|
||||
rm -rf "$W/s6/src/test"; cp "$AFTER_MAIN"/JsonConfig.java "$AFTER_MAIN"/SecurityConfig.java "$W/s6/src/main/java/com/ankurm/migration/"
|
||||
sed -i 's#<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc#<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-restclient</artifactId></dependency>\n <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-properties-migrator</artifactId><scope>runtime</scope></dependency>\n <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc#' "$W/s6/pom.xml"
|
||||
{ hdr "# s6 = s3 + spring-boot-properties-migrator (runtime scope)"
|
||||
mv_ "$W/s6" -DskipTests package | grep -E 'ERROR|BUILD'
|
||||
start migrator "$W/s6/target/migration-demo-1.0.0.jar" && echo "app started" || echo "app did not start"
|
||||
hdr "grep -iE 'propert|logging.file|migrat' run.log # what the migrator printed at start-up"
|
||||
grep -iE 'logging\.file|PropertiesMigration|The use of configuration keys|Property source|Reason|Replacement' "$W/run-migrator.log" | sed -E 's/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:.+]+ +//' | cut -c1-220 | head -20
|
||||
echo "(lines matching: $(grep -ciE 'logging\.file|PropertiesMigration' "$W/run-migrator.log"))"
|
||||
stop; } > "$OUT/05-properties-migrator.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 06 the migrated app
|
||||
{ hdr "mvn verify # after/ : Boot $BOOT_NEW, one starter per technology, -test companions, Jackson 3, new packages"
|
||||
stage a after
|
||||
mv_ "$W/a" verify > "$W/a.log"; grep -E 'Tests run:|CSRFPROBE|BUILD' "$W/a.log" | grep -v 'Time elapsed'
|
||||
echo; hdr "java -jar migration-demo-1.0.0.jar"
|
||||
probe after "$W/a/target/migration-demo-1.0.0.jar"; } > "$OUT/06-after-boot41.txt"
|
||||
cp "$OUT/06-after-boot41.txt" "$W/probe-after.txt"
|
||||
{ hdr "java -jar migration-demo-1.0.0.jar --spring.jackson.use-jackson2-defaults=true"
|
||||
start j2 "$W/a/target/migration-demo-1.0.0.jar" --spring.jackson.use-jackson2-defaults=true && g /summary; stop; } > "$W/probe-j2.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 07 Jackson order, side by side
|
||||
{ echo "# GET /summary on the same bean (id, title, createdAt, author declared in that order)"
|
||||
echo "Boot $BOOT_OLD (Jackson 2): $(grep -A1 '^GET /summary' "$W/probe-boot35.txt" | tail -1)"
|
||||
echo "Boot $BOOT_NEW (Jackson 3, defaults): $(grep -A1 '^GET /summary' "$W/probe-after.txt" | tail -1)"
|
||||
echo "Boot $BOOT_NEW + spring.jackson.use-jackson2-defaults: $(grep -A1 '^GET /summary' "$W/probe-j2.txt" | tail -1)"; } > "$OUT/07-jackson-property-order.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 08 test code
|
||||
stage t1 after; rm -rf "$W/t1/src/test"; mkdir -p "$W/t1/src/test/java/com/ankurm/migration"
|
||||
cp "$BEFORE_TEST"/GreetingControllerTest.java "$W/t1/src/test/java/com/ankurm/migration/"
|
||||
{ hdr "mvn test-compile # after/ pom and main code, but the Boot 3 GreetingControllerTest (@MockBean, old @AutoConfigureMockMvc package)"
|
||||
mv_ "$W/t1" test-compile > "$W/t1.log"; grep -E '^\[ERROR\] .*\.java' "$W/t1.log" | sed 's#^\[ERROR\] ##' | sort -u; grep -E 'BUILD' "$W/t1.log"; } > "$OUT/08-test-compile-errors.txt"
|
||||
stage t2 after; rm -rf "$W/t2/src/test"; mkdir -p "$W/t2/src/test/java/com/ankurm/migration"
|
||||
cp "$BEFORE_TEST"/MockFieldTest.java "$W/t2/src/test/java/com/ankurm/migration/"
|
||||
sed 's#org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc#org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc#' "$BEFORE_TEST"/CsrfProbeTest.java > "$W/t2/src/test/java/com/ankurm/migration/CsrfProbeTest.java"
|
||||
{ hdr "mvn test # after/ pom and main code + the Boot 3 MockFieldTest unchanged (compiles) and CsrfProbeTest (one import fixed)"
|
||||
mv_ "$W/t2" test > "$W/t2.log"; grep -E '^\[(ERROR|INFO)\] Tests run:|CSRFPROBE|^\[ERROR\] MockFieldTest|BUILD' "$W/t2.log" | grep -v 'Time elapsed'; } > "$OUT/09-test-runtime-failure.txt"
|
||||
bash "$HERE/scripts/security-dsl.sh" > /dev/null
|
||||
echo "done"; ls -l "$OUT"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Output 10: the Boot 3 SecurityConfig with ONLY its import repointed (SecurityProperties -> SecurityFilterProperties),
|
||||
# compiled with javac against the Boot 4.1.2 classpath that run-all.sh already resolved ($W/cp.txt).
|
||||
set -u
|
||||
HERE=$(cd "$(dirname "$0")/.." && pwd); W=${WORK:-/tmp/b4m-work}; OUT=$HERE/output/10-security-dsl-compile-errors.txt
|
||||
D=$W/sec; rm -rf "$D"; mkdir -p "$D/classes"
|
||||
sed 's#org.springframework.boot.autoconfigure.security.SecurityProperties#org.springframework.boot.security.autoconfigure.web.servlet.SecurityFilterProperties#; s#SecurityProperties.BASIC_AUTH_ORDER#SecurityFilterProperties.BASIC_AUTH_ORDER#' \
|
||||
"$HERE/before/src/main/java/com/ankurm/migration/SecurityConfig.java" > "$D/SecurityConfig.java"
|
||||
{ echo '$ javac SecurityConfig.java # Boot 3 file, import repointed to the 4.1.2 package; the old method-chaining DSL left as it was'
|
||||
javac -d "$D/classes" -cp "$(cat "$W/cp.txt")" "$D/SecurityConfig.java" 2>&1 | grep -v JAVA_TOOL | sed "s#$D/##"; } > "$OUT"
|
||||
cat "$OUT"
|
||||
@@ -0,0 +1,20 @@
|
||||
# boot42-otel
|
||||
|
||||
Companion module for the ankurm.com article *Spring Boot 4.2 OpenTelemetry: Semantic Conventions, Shared OTLP Settings and MDC Keys*.
|
||||
Everything runs against **Spring Boot 4.2.0-RC1** (a release candidate, **not GA**) and against **4.1.2** (GA) as the baseline. JDK 25.
|
||||
|
||||
| Path | What it is |
|
||||
|---|---|
|
||||
| `pom.xml` / `pom-41.xml` | the same project on 4.2.0-RC1 and on 4.1.2 |
|
||||
| `src/main/.../OtelApplication` | one endpoint, `GET /hello/{name}`, that logs a line |
|
||||
| `src/test/.../OtlpSink` | a 60-line OTLP/HTTP receiver: records path, headers and payload strings of every export request |
|
||||
| `src/test/.../ConventionsTest` | meters and span names for each `management.observations.conventions` value, including the start-up failure RC1 gives for `open-telemetry` |
|
||||
| `src/test/.../ConventionSpellingsTest` | seven spellings of the conventions value, each started for real: which start and which meter they produce |
|
||||
| `src/test/.../SharedOtlpTest` | `management.opentelemetry.otlp.*`: paths, merged headers, gzip, and signal-specific overrides |
|
||||
| `src/test/.../MdcAndLongTaskTimerTest` | custom MDC keys, and the active-observation LongTaskTimer that is no longer on by default |
|
||||
| `src/test/.../PrometheusNamesTest` | the `http_server_*` names a dashboard query sees under each convention |
|
||||
| `output/` | every transcript quoted in the article; `./scripts/run-all.sh` regenerates them |
|
||||
|
||||
Run: `./scripts/run-all.sh`. `ConventionsTest` pins the RC1 behaviour on purpose; when a later build changes it, that test fails and the article needs updating.
|
||||
|
||||
There is deliberately no `docs/` folder: the explanations live in the article.
|
||||
@@ -0,0 +1,37 @@
|
||||
# 01-conventions-metrics-and-spans (Spring Boot 4.1.2, JDK 25)
|
||||
|
||||
== management.observations.conventions=(property not set)
|
||||
-- meters whose name contains 'http':
|
||||
http.server.requests [error=none, exception=none, method=GET, outcome=SUCCESS, status=200, uri=/hello/{name}]
|
||||
http.server.requests.active [exception=none, method=GET, outcome=SUCCESS, status=200, uri=UNKNOWN]
|
||||
-- span-related strings in the OTLP trace payload (1 request(s)):
|
||||
/hello/ankurJ
|
||||
/hello/{name}z
|
||||
http get /hello/{name}0
|
||||
|
||||
== management.observations.conventions=micrometer
|
||||
-- meters whose name contains 'http':
|
||||
http.server.requests [error=none, exception=none, method=GET, outcome=SUCCESS, status=200, uri=/hello/{name}]
|
||||
http.server.requests.active [exception=none, method=GET, outcome=SUCCESS, status=200, uri=UNKNOWN]
|
||||
-- span-related strings in the OTLP trace payload (1 request(s)):
|
||||
/hello/ankurJ
|
||||
/hello/{name}z
|
||||
http get /hello/{name}0
|
||||
|
||||
== management.observations.conventions=open-telemetry
|
||||
-- meters whose name contains 'http':
|
||||
http.server.requests [error=none, exception=none, method=GET, outcome=SUCCESS, status=200, uri=/hello/{name}]
|
||||
http.server.requests.active [exception=none, method=GET, outcome=SUCCESS, status=200, uri=UNKNOWN]
|
||||
-- span-related strings in the OTLP trace payload (1 request(s)):
|
||||
/hello/ankurJ
|
||||
/hello/{name}z
|
||||
http get /hello/{name}0
|
||||
|
||||
== management.observations.conventions=opentelemetry
|
||||
-- meters whose name contains 'http':
|
||||
http.server.requests [error=none, exception=none, method=GET, outcome=SUCCESS, status=200, uri=/hello/{name}]
|
||||
http.server.requests.active [exception=none, method=GET, outcome=SUCCESS, status=200, uri=UNKNOWN]
|
||||
-- span-related strings in the OTLP trace payload (1 request(s)):
|
||||
/hello/ankurJ
|
||||
/hello/{name}z
|
||||
http get /hello/{name}0
|
||||
@@ -0,0 +1,29 @@
|
||||
# 01-conventions-metrics-and-spans (Spring Boot 4.2.0-RC1, JDK 25)
|
||||
|
||||
== management.observations.conventions=(property not set)
|
||||
-- meters whose name contains 'http':
|
||||
http.server.requests [error=none, exception=none, method=GET, outcome=SUCCESS, status=200, uri=/hello/{name}]
|
||||
-- span-related strings in the OTLP trace payload (1 request(s)):
|
||||
/hello/ankurJ
|
||||
/hello/{name}z
|
||||
http get /hello/{name}0
|
||||
|
||||
== management.observations.conventions=micrometer
|
||||
-- meters whose name contains 'http':
|
||||
http.server.requests [error=none, exception=none, method=GET, outcome=SUCCESS, status=200, uri=/hello/{name}]
|
||||
-- span-related strings in the OTLP trace payload (1 request(s)):
|
||||
/hello/ankurJ
|
||||
/hello/{name}z
|
||||
http get /hello/{name}0
|
||||
|
||||
== management.observations.conventions=open-telemetry
|
||||
-- application FAILED to start
|
||||
NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.http.server.observation.ServerRequestObservationConvention' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
|
||||
|
||||
== management.observations.conventions=opentelemetry
|
||||
-- meters whose name contains 'http':
|
||||
http.server.request.duration [error.type=none, error=none, http.request.method=GET, http.response.status_code=200, http.route=/hello/{name}, outcome=SUCCESS, url.scheme=http]
|
||||
-- span-related strings in the OTLP trace payload (1 request(s)):
|
||||
/hello/ankurJ
|
||||
/hello/{name}J
|
||||
GET /hello/{name}0
|
||||
@@ -0,0 +1,7 @@
|
||||
# 02-shared-otlp-endpoint (Spring Boot 4.1.2, JDK 25)
|
||||
management.opentelemetry.otlp.endpoint = <sink> (one property, no per-signal URLs)
|
||||
management.opentelemetry.otlp.headers = Authorization: Bearer shared-token
|
||||
management.opentelemetry.otlp.compression = gzip
|
||||
|
||||
requests that reached the sink:
|
||||
(none: 4.1.2 ignores the shared properties and exports to its default localhost:4318)
|
||||
@@ -0,0 +1,8 @@
|
||||
# 02-shared-otlp-endpoint (Spring Boot 4.2.0-RC1, JDK 25)
|
||||
management.opentelemetry.otlp.endpoint = <sink> (one property, no per-signal URLs)
|
||||
management.opentelemetry.otlp.headers = Authorization: Bearer shared-token
|
||||
management.opentelemetry.otlp.compression = gzip
|
||||
|
||||
requests that reached the sink:
|
||||
POST /v1/metrics Authorization=Bearer shared-token Content-Encoding=gzip
|
||||
POST /v1/traces Authorization=Bearer shared-token Content-Encoding=gzip
|
||||
@@ -0,0 +1,9 @@
|
||||
# 03-signal-specific-overrides-shared (Spring Boot 4.1.2, JDK 25)
|
||||
shared endpoint = <sink>
|
||||
tracing.export.otlp.endpoint = <sink>/custom/spans
|
||||
shared header Authorization = Bearer shared-token
|
||||
shared header X-Shared = shared-only
|
||||
tracing.export.otlp.headers.Authorization = Bearer traces-token
|
||||
|
||||
requests that reached the sink:
|
||||
POST /custom/spans Authorization=Bearer traces-token X-Shared=null
|
||||
@@ -0,0 +1,10 @@
|
||||
# 03-signal-specific-overrides-shared (Spring Boot 4.2.0-RC1, JDK 25)
|
||||
shared endpoint = <sink>
|
||||
tracing.export.otlp.endpoint = <sink>/custom/spans
|
||||
shared header Authorization = Bearer shared-token
|
||||
shared header X-Shared = shared-only
|
||||
tracing.export.otlp.headers.Authorization = Bearer traces-token
|
||||
|
||||
requests that reached the sink:
|
||||
POST /custom/spans Authorization=Bearer traces-token X-Shared=shared-only
|
||||
POST /v1/metrics Authorization=Bearer shared-token X-Shared=shared-only
|
||||
@@ -0,0 +1,8 @@
|
||||
# 04-mdc-keys (Spring Boot 4.1.2, JDK 25)
|
||||
management.tracing.mdc.trace-id-key = trace_id
|
||||
management.tracing.mdc.span-id-key = span_id
|
||||
log pattern correlation part reads both MDC keys
|
||||
|
||||
log line: INFO 4192 --- [boot42-otel] [o-auto-1-exec-1] default[<32-hex-trace-id>] custom[] c.a.o.OtelApplication$HelloController : handling hello for ankur
|
||||
default key traceId populated: true
|
||||
custom key trace_id populated: false
|
||||
@@ -0,0 +1,8 @@
|
||||
# 04-mdc-keys (Spring Boot 4.2.0-RC1, JDK 25)
|
||||
management.tracing.mdc.trace-id-key = trace_id
|
||||
management.tracing.mdc.span-id-key = span_id
|
||||
log pattern correlation part reads both MDC keys
|
||||
|
||||
log line: INFO 3810 --- [boot42-otel] [o-auto-1-exec-1] default[] custom[<32-hex-trace-id>] c.a.o.OtelApplication$HelloController : handling hello for ankur
|
||||
default key traceId populated: false
|
||||
custom key trace_id populated: true
|
||||
@@ -0,0 +1,11 @@
|
||||
# 05-active-long-task-timer (Spring Boot 4.1.2, JDK 25)
|
||||
|
||||
== (default)
|
||||
http.server.requests (TIMER)
|
||||
http.server.requests.active (LONG_TASK_TIMER)
|
||||
http.server.requests.active present: true
|
||||
|
||||
== management.metrics.observations.include-active-long-task-timer=true
|
||||
http.server.requests (TIMER)
|
||||
http.server.requests.active (LONG_TASK_TIMER)
|
||||
http.server.requests.active present: true
|
||||
@@ -0,0 +1,10 @@
|
||||
# 05-active-long-task-timer (Spring Boot 4.2.0-RC1, JDK 25)
|
||||
|
||||
== (default)
|
||||
http.server.requests (TIMER)
|
||||
http.server.requests.active present: false
|
||||
|
||||
== management.metrics.observations.include-active-long-task-timer=true
|
||||
http.server.requests (TIMER)
|
||||
http.server.requests.active (LONG_TASK_TIMER)
|
||||
http.server.requests.active present: true
|
||||
@@ -0,0 +1,19 @@
|
||||
# 06-prometheus-names (Spring Boot 4.1.2, JDK 25)
|
||||
|
||||
== management.observations.conventions=micrometer
|
||||
http_server_requests_active_seconds_count
|
||||
http_server_requests_active_seconds_max
|
||||
http_server_requests_active_seconds_sum
|
||||
http_server_requests_seconds_count
|
||||
http_server_requests_seconds_max
|
||||
http_server_requests_seconds_sum
|
||||
sample: http_server_requests_active_seconds_count{exception="none",method="GET",outcome="SUCCESS",status="200",uri="UNKNOWN"}
|
||||
|
||||
== management.observations.conventions=opentelemetry
|
||||
http_server_requests_active_seconds_count
|
||||
http_server_requests_active_seconds_max
|
||||
http_server_requests_active_seconds_sum
|
||||
http_server_requests_seconds_count
|
||||
http_server_requests_seconds_max
|
||||
http_server_requests_seconds_sum
|
||||
sample: http_server_requests_active_seconds_count{exception="none",method="GET",outcome="SUCCESS",status="200",uri="UNKNOWN"}
|
||||
@@ -0,0 +1,13 @@
|
||||
# 06-prometheus-names (Spring Boot 4.2.0-RC1, JDK 25)
|
||||
|
||||
== management.observations.conventions=micrometer
|
||||
http_server_requests_seconds_count
|
||||
http_server_requests_seconds_max
|
||||
http_server_requests_seconds_sum
|
||||
sample: http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/hello/{name}"}
|
||||
|
||||
== management.observations.conventions=opentelemetry
|
||||
http_server_request_duration_seconds_count
|
||||
http_server_request_duration_seconds_max
|
||||
http_server_request_duration_seconds_sum
|
||||
sample: http_server_request_duration_seconds_count{error="none",error_type="none",http_request_method="GET",http_response_status_code="200",http_route="/hello/{name}",outcome="SUCCESS",url_scheme="http"}
|
||||
@@ -0,0 +1,8 @@
|
||||
# 07-conventions-spellings (Spring Boot 4.1.2, JDK 25)
|
||||
open-telemetry -> starts, server meter: [http.server.requests]
|
||||
open_telemetry -> starts, server meter: [http.server.requests]
|
||||
OPEN_TELEMETRY -> starts, server meter: [http.server.requests]
|
||||
opentelemetry -> starts, server meter: [http.server.requests]
|
||||
openTelemetry -> starts, server meter: [http.server.requests]
|
||||
micrometer -> starts, server meter: [http.server.requests]
|
||||
MICROMETER -> starts, server meter: [http.server.requests]
|
||||
@@ -0,0 +1,8 @@
|
||||
# 07-conventions-spellings (Spring Boot 4.2.0-RC1, JDK 25)
|
||||
open-telemetry -> FAILS to start
|
||||
open_telemetry -> starts, server meter: [http.server.request.duration]
|
||||
OPEN_TELEMETRY -> starts, server meter: [http.server.request.duration]
|
||||
opentelemetry -> starts, server meter: [http.server.request.duration]
|
||||
openTelemetry -> starts, server meter: [http.server.request.duration]
|
||||
micrometer -> starts, server meter: [http.server.requests]
|
||||
MICROMETER -> starts, server meter: [http.server.requests]
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ankurm</groupId>
|
||||
<artifactId>boot42-otel</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>boot42-otel</name>
|
||||
<description>Spring Boot 4.2 OpenTelemetry semantic conventions, shared OTLP settings and MDC keys, run against 4.2.0-RC1 and 4.1.2</description>
|
||||
|
||||
<properties>
|
||||
<java.version>25</java.version>
|
||||
<boot.label>4.1.2</boot.label>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-opentelemetry</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<boot.label>${boot.label}</boot.label>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.2.0-RC1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ankurm</groupId>
|
||||
<artifactId>boot42-otel</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>boot42-otel</name>
|
||||
<description>Spring Boot 4.2 OpenTelemetry semantic conventions, shared OTLP settings and MDC keys, run against 4.2.0-RC1 and 4.1.2</description>
|
||||
|
||||
<properties>
|
||||
<java.version>25</java.version>
|
||||
<boot.label>4.2.0-RC1</boot.label>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-opentelemetry</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<boot.label>${boot.label}</boot.label>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates every file in output/ on Spring Boot 4.2.0-RC1 and on the 4.1.2 baseline.
|
||||
# Needs JDK 25 and Maven 3.9 on PATH. Timing-sensitive lines are not captured on purpose.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mvn -B -q test
|
||||
mvn -B -q -f pom-41.xml test
|
||||
echo "done: $(ls output | wc -l) files in output/"
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@SpringBootApplication
|
||||
public class OtelApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OtelApplication.class, args);
|
||||
}
|
||||
|
||||
@RestController
|
||||
static class HelloController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HelloController.class);
|
||||
|
||||
// The explicit name avoids the -parameters trap on standalone reactors.
|
||||
@GetMapping("/hello/{name}")
|
||||
String hello(@PathVariable("name") String name) {
|
||||
log.info("handling hello for {}", name);
|
||||
return "hello " + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
spring.application.name=boot42-otel
|
||||
management.endpoints.web.exposure.include=health,metrics,prometheus
|
||||
management.tracing.sampling.probability=1.0
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import io.micrometer.core.instrument.Meter;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
/** Starts the demo application on a random port with the given properties. */
|
||||
final class Apps {
|
||||
|
||||
private Apps() {
|
||||
}
|
||||
|
||||
static ConfigurableApplicationContext start(String... properties) {
|
||||
List<String> props = new ArrayList<>(List.of("server.port=0", "spring.main.banner-mode=off"));
|
||||
props.addAll(List.of(properties));
|
||||
return new SpringApplicationBuilder(OtelApplication.class).web(WebApplicationType.SERVLET)
|
||||
.properties(props.toArray(String[]::new))
|
||||
.run();
|
||||
}
|
||||
|
||||
static String call(ConfigurableApplicationContext ctx, String path) {
|
||||
String port = ctx.getEnvironment().getProperty("local.server.port");
|
||||
return RestClient.create().get().uri("http://localhost:" + port + path).retrieve().body(String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The server observation stops after the response bytes are on the wire, so a client that
|
||||
* reads the registry immediately can win the race and see nothing. Poll for up to 5 seconds.
|
||||
*/
|
||||
static void awaitHttpMeter(MeterRegistry registry) throws InterruptedException {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (registry.getMeters().stream().anyMatch(m -> m.getId().getName().startsWith("http.server.request")
|
||||
&& !m.getId().getName().endsWith(".active"))) {
|
||||
return;
|
||||
}
|
||||
Thread.sleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
/** One line per meter whose name mentions http: name, then sorted tag key=value pairs. */
|
||||
static List<String> httpMeters(MeterRegistry registry) {
|
||||
TreeSet<String> out = new TreeSet<>();
|
||||
for (Meter m : registry.getMeters()) {
|
||||
String name = m.getId().getName();
|
||||
if (name.contains("http")) {
|
||||
List<String> tags = new ArrayList<>();
|
||||
for (Tag t : m.getId().getTags()) {
|
||||
tags.add(t.getKey() + "=" + t.getValue());
|
||||
}
|
||||
tags.sort(String::compareTo);
|
||||
out.add(name + " " + tags);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(out);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* The reference documentation says management.observations.conventions=open-telemetry. This
|
||||
* starts the application once per spelling and records whether it starts and which server HTTP
|
||||
* meter it ends up with. On 4.2.0-RC1 the documented spelling does not start.
|
||||
*/
|
||||
class ConventionSpellingsTest {
|
||||
|
||||
@Test
|
||||
void spellings() throws Exception {
|
||||
Transcript t = new Transcript("07-conventions-spellings");
|
||||
Map<String, String> outcome = new LinkedHashMap<>();
|
||||
for (String value : List.of("open-telemetry", "open_telemetry", "OPEN_TELEMETRY", "opentelemetry",
|
||||
"openTelemetry", "micrometer", "MICROMETER")) {
|
||||
String result;
|
||||
try {
|
||||
ConfigurableApplicationContext ctx = Apps.start("management.observations.conventions=" + value,
|
||||
"management.otlp.metrics.export.enabled=false");
|
||||
Apps.call(ctx, "/hello/x");
|
||||
MeterRegistry registry = ctx.getBean(MeterRegistry.class);
|
||||
Apps.awaitHttpMeter(registry);
|
||||
result = "starts, server meter: " + registry.getMeters().stream()
|
||||
.map(m -> m.getId().getName())
|
||||
.filter(n -> n.startsWith("http.server.request") && !n.endsWith(".active"))
|
||||
.distinct()
|
||||
.sorted()
|
||||
.toList();
|
||||
ctx.close();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
result = "FAILS to start";
|
||||
}
|
||||
outcome.put(value, result);
|
||||
t.line(String.format("%-16s -> %s", value, result));
|
||||
}
|
||||
t.write();
|
||||
if (Transcript.LABEL.equals("4.2.0-RC1")) {
|
||||
assertThat(outcome.get("open-telemetry")).isEqualTo("FAILS to start");
|
||||
assertThat(outcome.get("opentelemetry")).contains("http.server.request.duration");
|
||||
assertThat(outcome.get("micrometer")).contains("http.server.requests");
|
||||
}
|
||||
else if (!Transcript.is42()) {
|
||||
assertThat(outcome.values()).allMatch(v -> v.contains("http.server.requests"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* One request against /hello/{name}, measured with each value of
|
||||
* management.observations.conventions (and with the property absent). Writes the HTTP meter names
|
||||
* and tags, and the span-related strings found in the OTLP trace payload. A start-up failure is
|
||||
* recorded, not hidden.
|
||||
*/
|
||||
class ConventionsTest {
|
||||
|
||||
@Test
|
||||
void metricsAndSpans() throws Exception {
|
||||
Transcript t = new Transcript("01-conventions-metrics-and-spans");
|
||||
java.util.Map<String, List<String>> meters = new java.util.LinkedHashMap<>();
|
||||
java.util.Map<String, String> failures = new java.util.LinkedHashMap<>();
|
||||
for (String mode : List.of("(property not set)", "micrometer", "open-telemetry", "opentelemetry")) {
|
||||
try (OtlpSink sink = new OtlpSink()) {
|
||||
t.line("");
|
||||
t.line("== management.observations.conventions=" + mode);
|
||||
ConfigurableApplicationContext ctx = null;
|
||||
try {
|
||||
String[] props = mode.startsWith("(")
|
||||
? new String[] { "management.otlp.metrics.export.enabled=false",
|
||||
"management.opentelemetry.tracing.export.otlp.endpoint=" + sink.baseUrl() + "/v1/traces" }
|
||||
: new String[] { "management.observations.conventions=" + mode,
|
||||
"management.otlp.metrics.export.enabled=false",
|
||||
"management.opentelemetry.tracing.export.otlp.endpoint=" + sink.baseUrl() + "/v1/traces" };
|
||||
ctx = Apps.start(props);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Throwable root = ex;
|
||||
while (root.getCause() != null) {
|
||||
root = root.getCause();
|
||||
}
|
||||
t.line("-- application FAILED to start");
|
||||
t.line(" " + root.getClass().getSimpleName() + ": " + firstLine(root.getMessage()));
|
||||
failures.put(mode, root.getClass().getSimpleName());
|
||||
continue;
|
||||
}
|
||||
Apps.call(ctx, "/hello/ankur");
|
||||
MeterRegistry registry = ctx.getBean(MeterRegistry.class);
|
||||
Apps.awaitHttpMeter(registry);
|
||||
t.line("-- meters whose name contains 'http':");
|
||||
List<String> found = Apps.httpMeters(registry);
|
||||
meters.put(mode, found);
|
||||
found.forEach(l -> t.line(" " + l));
|
||||
ctx.close();
|
||||
Thread.sleep(500);
|
||||
t.line("-- span-related strings in the OTLP trace payload (" + sink.hits().size() + " request(s)):");
|
||||
sink.hits().stream()
|
||||
.flatMap(h -> h.strings().stream())
|
||||
.filter(s -> s.contains("hello") || s.contains("GET") || s.contains("get "))
|
||||
.distinct()
|
||||
.forEach(s -> t.line(" " + s));
|
||||
}
|
||||
}
|
||||
t.write();
|
||||
if (Transcript.is42()) {
|
||||
assertThat(meters.get("(property not set)")).anyMatch(l -> l.startsWith("http.server.requests "));
|
||||
assertThat(meters.get("micrometer")).anyMatch(l -> l.startsWith("http.server.requests "));
|
||||
assertThat(meters.get("opentelemetry")).anyMatch(l -> l.startsWith("http.server.request.duration "));
|
||||
assertThat(meters.get("opentelemetry")).noneMatch(l -> l.startsWith("http.server.requests "));
|
||||
}
|
||||
if (Transcript.LABEL.equals("4.2.0-RC1")) {
|
||||
// Pinned on purpose: when this stops failing, the RC1 section of the article is stale.
|
||||
assertThat(failures).containsKey("open-telemetry");
|
||||
assertThat(failures).doesNotContainKey("opentelemetry");
|
||||
}
|
||||
else if (!Transcript.is42()) {
|
||||
assertThat(failures).isEmpty();
|
||||
assertThat(meters.get("opentelemetry")).anyMatch(l -> l.startsWith("http.server.requests "));
|
||||
}
|
||||
}
|
||||
|
||||
private static String firstLine(String s) {
|
||||
if (s == null) {
|
||||
return "";
|
||||
}
|
||||
int nl = s.indexOf('\n');
|
||||
String line = nl < 0 ? s : s.substring(0, nl);
|
||||
return line.length() > 260 ? line.substring(0, 260) + "..." : line;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import io.micrometer.core.instrument.Meter;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Two smaller 4.2 changes that break dashboards and log queries rather than builds: the MDC keys
|
||||
* that carry the trace and span ids, and the active-observation LongTaskTimer that is no longer
|
||||
* created by default.
|
||||
*/
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
class MdcAndLongTaskTimerTest {
|
||||
|
||||
@Test
|
||||
void mdcKeys(CapturedOutput output) {
|
||||
Transcript t = new Transcript("04-mdc-keys");
|
||||
// The pattern reads both the default key names and the custom ones, so one log line shows
|
||||
// which key the tracing bridge really populated.
|
||||
ConfigurableApplicationContext ctx = Apps.start("management.otlp.metrics.export.enabled=false",
|
||||
"management.tracing.mdc.trace-id-key=trace_id", "management.tracing.mdc.span-id-key=span_id",
|
||||
"logging.pattern.correlation=default[%X{traceId:-}] custom[%X{trace_id:-}] ");
|
||||
Apps.call(ctx, "/hello/ankur");
|
||||
ctx.close();
|
||||
String line = output.getAll().lines().filter(l -> l.contains("handling hello for ankur")).findFirst().orElseThrow();
|
||||
String correlation = line.substring(line.indexOf("default["), line.indexOf("] : ") > 0 ? line.indexOf("] :") : line.length());
|
||||
t.line("management.tracing.mdc.trace-id-key = trace_id");
|
||||
t.line("management.tracing.mdc.span-id-key = span_id");
|
||||
t.line("log pattern correlation part reads both MDC keys");
|
||||
t.line("");
|
||||
t.line("log line: " + line.replaceAll("^\\S+\\s+", "").replaceAll("(?<=\\[)[0-9a-f]{32}(?=\\])", "<32-hex-trace-id>"));
|
||||
boolean defaultKeyFilled = line.matches(".*default\\[[0-9a-f]{32}\\].*");
|
||||
boolean customKeyFilled = line.matches(".*custom\\[[0-9a-f]{32}\\].*");
|
||||
t.line("default key traceId populated: " + defaultKeyFilled);
|
||||
t.line("custom key trace_id populated: " + customKeyFilled);
|
||||
if (Transcript.is42()) {
|
||||
assertThat(customKeyFilled).isTrue();
|
||||
assertThat(defaultKeyFilled).isFalse();
|
||||
}
|
||||
else {
|
||||
assertThat(customKeyFilled).isFalse();
|
||||
assertThat(defaultKeyFilled).isTrue();
|
||||
}
|
||||
t.write();
|
||||
}
|
||||
|
||||
@Test
|
||||
void activeLongTaskTimer() throws Exception {
|
||||
Transcript t = new Transcript("05-active-long-task-timer");
|
||||
for (String setting : List.of("(default)", "management.metrics.observations.include-active-long-task-timer=true")) {
|
||||
ConfigurableApplicationContext ctx = setting.startsWith("(")
|
||||
? Apps.start("management.otlp.metrics.export.enabled=false")
|
||||
: Apps.start("management.otlp.metrics.export.enabled=false", setting);
|
||||
Apps.call(ctx, "/hello/ankur");
|
||||
MeterRegistry registry = ctx.getBean(MeterRegistry.class);
|
||||
Apps.awaitHttpMeter(registry);
|
||||
TreeSet<String> names = new TreeSet<>();
|
||||
for (Meter m : registry.getMeters()) {
|
||||
if (m.getId().getName().startsWith("http.server")) {
|
||||
names.add(m.getId().getName() + " (" + m.getId().getType() + ")");
|
||||
}
|
||||
}
|
||||
t.line("");
|
||||
t.line("== " + setting);
|
||||
names.forEach(n -> t.line(" " + n));
|
||||
boolean active = names.stream().anyMatch(n -> n.startsWith("http.server.requests.active"));
|
||||
t.line(" http.server.requests.active present: " + active);
|
||||
if (Transcript.is42()) {
|
||||
assertThat(active).isEqualTo(!setting.startsWith("("));
|
||||
}
|
||||
else if (setting.startsWith("(")) {
|
||||
assertThat(active).isTrue();
|
||||
}
|
||||
ctx.close();
|
||||
}
|
||||
t.write();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
|
||||
/**
|
||||
* A tiny OTLP/HTTP receiver: it accepts any POST, answers 200 with an empty protobuf body and
|
||||
* remembers the path, a few headers and the (decompressed) payload bytes. Enough to see where an
|
||||
* exporter really sends data, with which headers, and which strings are inside the payload.
|
||||
*/
|
||||
final class OtlpSink implements AutoCloseable {
|
||||
|
||||
record Hit(String path, String authorization, String xShared, String contentEncoding, String contentType, byte[] body) {
|
||||
|
||||
/** Printable ASCII runs of at least 6 characters, a poor man's protobuf string reader. */
|
||||
List<String> strings() {
|
||||
TreeSet<String> out = new TreeSet<>();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : body) {
|
||||
if (b >= 32 && b < 127) {
|
||||
sb.append((char) b);
|
||||
}
|
||||
else {
|
||||
flush(sb, out);
|
||||
}
|
||||
}
|
||||
flush(sb, out);
|
||||
return new ArrayList<>(out);
|
||||
}
|
||||
|
||||
private static void flush(StringBuilder sb, TreeSet<String> out) {
|
||||
if (sb.length() >= 6) {
|
||||
out.add(sb.toString());
|
||||
}
|
||||
sb.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
private final HttpServer server;
|
||||
private final List<Hit> hits = new CopyOnWriteArrayList<>();
|
||||
|
||||
OtlpSink() throws IOException {
|
||||
server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
|
||||
server.createContext("/", exchange -> {
|
||||
byte[] raw = exchange.getRequestBody().readAllBytes();
|
||||
String enc = exchange.getRequestHeaders().getFirst("Content-Encoding");
|
||||
byte[] body = raw;
|
||||
if ("gzip".equalsIgnoreCase(enc)) {
|
||||
try (InputStream in = new GZIPInputStream(new java.io.ByteArrayInputStream(raw))) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
in.transferTo(bos);
|
||||
body = bos.toByteArray();
|
||||
}
|
||||
}
|
||||
hits.add(new Hit(exchange.getRequestURI().getPath(), exchange.getRequestHeaders().getFirst("Authorization"),
|
||||
exchange.getRequestHeaders().getFirst("X-Shared"), enc, exchange.getRequestHeaders().getFirst("Content-Type"), body));
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/x-protobuf");
|
||||
exchange.sendResponseHeaders(200, -1);
|
||||
exchange.close();
|
||||
});
|
||||
server.start();
|
||||
}
|
||||
|
||||
int port() {
|
||||
return server.getAddress().getPort();
|
||||
}
|
||||
|
||||
String baseUrl() {
|
||||
return "http://localhost:" + port();
|
||||
}
|
||||
|
||||
List<Hit> hits() {
|
||||
return List.copyOf(hits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
server.stop(0);
|
||||
hits.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* What a dashboard query sees. Scrapes /actuator/prometheus after one request and lists the
|
||||
* http_server* families and one labelled sample, for the default conventions and for the
|
||||
* open-telemetry conventions (spelled the way RC1 accepts it).
|
||||
*/
|
||||
class PrometheusNamesTest {
|
||||
|
||||
@Test
|
||||
void promNames() throws Exception {
|
||||
Transcript t = new Transcript("06-prometheus-names");
|
||||
List<String> modes = List.of("micrometer", "opentelemetry");
|
||||
java.util.Map<String, List<String>> families = new java.util.LinkedHashMap<>();
|
||||
for (String mode : modes) {
|
||||
ConfigurableApplicationContext ctx = Apps.start("management.observations.conventions=" + mode,
|
||||
"management.otlp.metrics.export.enabled=false");
|
||||
Apps.call(ctx, "/hello/ankur");
|
||||
io.micrometer.core.instrument.MeterRegistry registry = ctx.getBean(io.micrometer.core.instrument.MeterRegistry.class);
|
||||
Apps.awaitHttpMeter(registry);
|
||||
String port = ctx.getEnvironment().getProperty("local.server.port");
|
||||
String body = RestClient.create().get().uri("http://localhost:" + port + "/actuator/prometheus")
|
||||
.retrieve().body(String.class);
|
||||
TreeSet<String> names = new TreeSet<>();
|
||||
String sample = "";
|
||||
for (String line : body.split("\n")) {
|
||||
if (line.startsWith("http_server")) {
|
||||
names.add(line.substring(0, line.indexOf('{') > 0 ? line.indexOf('{') : line.indexOf(' ')));
|
||||
if (line.contains("_count{") && sample.isEmpty()) {
|
||||
sample = line.substring(0, line.lastIndexOf(' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
t.line("");
|
||||
t.line("== management.observations.conventions=" + mode);
|
||||
names.forEach(n -> t.line(" " + n));
|
||||
t.line(" sample: " + sample);
|
||||
families.put(mode, new ArrayList<>(names));
|
||||
ctx.close();
|
||||
}
|
||||
t.write();
|
||||
if (Transcript.is42()) {
|
||||
assertThat(families.get("micrometer")).contains("http_server_requests_seconds_count");
|
||||
assertThat(families.get("opentelemetry")).contains("http_server_request_duration_seconds_count");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* 4.2.0-M2 added management.opentelemetry.otlp.{endpoint,headers,compression}, shared by traces,
|
||||
* logs and metrics. A local OTLP receiver shows which paths the exporters really call, with which
|
||||
* headers, and what a signal-specific property does to the shared one.
|
||||
*/
|
||||
class SharedOtlpTest {
|
||||
|
||||
@Test
|
||||
void sharedEndpointHeadersAndCompression() throws Exception {
|
||||
Transcript t = new Transcript("02-shared-otlp-endpoint");
|
||||
try (OtlpSink sink = new OtlpSink()) {
|
||||
ConfigurableApplicationContext ctx = Apps.start(
|
||||
"management.opentelemetry.otlp.endpoint=" + sink.baseUrl(),
|
||||
"management.opentelemetry.otlp.headers.Authorization=Bearer shared-token",
|
||||
"management.opentelemetry.otlp.compression=gzip",
|
||||
"management.otlp.metrics.export.step=1s");
|
||||
Apps.call(ctx, "/hello/ankur");
|
||||
Thread.sleep(2500);
|
||||
ctx.close();
|
||||
Thread.sleep(500);
|
||||
t.line("management.opentelemetry.otlp.endpoint = <sink> (one property, no per-signal URLs)");
|
||||
t.line("management.opentelemetry.otlp.headers = Authorization: Bearer shared-token");
|
||||
t.line("management.opentelemetry.otlp.compression = gzip");
|
||||
t.line("");
|
||||
TreeSet<String> seen = new TreeSet<>();
|
||||
for (OtlpSink.Hit h : sink.hits()) {
|
||||
seen.add(String.format("POST %-12s Authorization=%s Content-Encoding=%s", h.path(), h.authorization(),
|
||||
h.contentEncoding()));
|
||||
}
|
||||
t.line("requests that reached the sink:");
|
||||
seen.forEach(l -> t.line(" " + l));
|
||||
if (Transcript.is42()) {
|
||||
assertThat(seen).anyMatch(l -> l.contains("/v1/traces") && l.contains("Bearer shared-token") && l.contains("gzip"));
|
||||
assertThat(seen).anyMatch(l -> l.contains("/v1/metrics") && l.contains("Bearer shared-token") && l.contains("gzip"));
|
||||
}
|
||||
else {
|
||||
assertThat(sink.hits()).isEmpty();
|
||||
t.line(" (none: 4.1.2 ignores the shared properties and exports to its default localhost:4318)");
|
||||
}
|
||||
}
|
||||
t.write();
|
||||
}
|
||||
|
||||
@Test
|
||||
void signalSpecificPropertyWins() throws Exception {
|
||||
Transcript t = new Transcript("03-signal-specific-overrides-shared");
|
||||
try (OtlpSink sink = new OtlpSink()) {
|
||||
ConfigurableApplicationContext ctx = Apps.start(
|
||||
"management.opentelemetry.otlp.endpoint=" + sink.baseUrl(),
|
||||
"management.opentelemetry.otlp.headers.Authorization=Bearer shared-token",
|
||||
"management.opentelemetry.otlp.headers.X-Shared=shared-only",
|
||||
"management.opentelemetry.tracing.export.otlp.endpoint=" + sink.baseUrl() + "/custom/spans",
|
||||
"management.opentelemetry.tracing.export.otlp.headers.Authorization=Bearer traces-token",
|
||||
"management.otlp.metrics.export.step=1s");
|
||||
Apps.call(ctx, "/hello/ankur");
|
||||
Thread.sleep(2500);
|
||||
ctx.close();
|
||||
Thread.sleep(500);
|
||||
t.line("shared endpoint = <sink>");
|
||||
t.line("tracing.export.otlp.endpoint = <sink>/custom/spans");
|
||||
t.line("shared header Authorization = Bearer shared-token");
|
||||
t.line("shared header X-Shared = shared-only");
|
||||
t.line("tracing.export.otlp.headers.Authorization = Bearer traces-token");
|
||||
t.line("");
|
||||
List<String> lines = sink.hits().stream()
|
||||
.map(h -> String.format("POST %-14s Authorization=%s X-Shared=%s", h.path(), h.authorization(), h.xShared()))
|
||||
.distinct()
|
||||
.sorted()
|
||||
.toList();
|
||||
t.line("requests that reached the sink:");
|
||||
lines.forEach(l -> t.line(" " + l));
|
||||
if (Transcript.is42()) {
|
||||
assertThat(lines).anyMatch(l -> l.contains("/custom/spans") && l.contains("Bearer traces-token")
|
||||
&& l.contains("X-Shared=shared-only"));
|
||||
assertThat(lines).anyMatch(l -> l.contains("/v1/metrics") && l.contains("Bearer shared-token")
|
||||
&& l.contains("X-Shared=shared-only"));
|
||||
assertThat(lines).noneMatch(l -> l.contains("/custom/spans/v1/traces"));
|
||||
}
|
||||
}
|
||||
t.write();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ankurm.otel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** Collects lines and writes output/NN-name[-on-4.1.2].txt. Tests assert what they write. */
|
||||
final class Transcript {
|
||||
|
||||
static final String LABEL = System.getProperty("boot.label", "4.2.0-RC1");
|
||||
|
||||
static boolean is42() {
|
||||
return LABEL.startsWith("4.2");
|
||||
}
|
||||
|
||||
private final List<String> lines = new ArrayList<>();
|
||||
private final Path file;
|
||||
|
||||
Transcript(String name) {
|
||||
String suffix = is42() ? "" : "-on-" + LABEL;
|
||||
this.file = Path.of("output", name + suffix + ".txt");
|
||||
line("# " + name + " (Spring Boot " + LABEL + ", JDK " + Runtime.version().feature() + ")");
|
||||
}
|
||||
|
||||
Transcript line(String s) {
|
||||
lines.add(s);
|
||||
return this;
|
||||
}
|
||||
|
||||
void write() {
|
||||
try {
|
||||
Files.createDirectories(file.getParent());
|
||||
Files.write(file, lines);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user