Skip to content

feat: add java-21-sample with virtual threads and SSL health indicator#83

Merged
dingmeng-xue merged 1 commit into
Azure-Samples:mainfrom
dingmeng-xue:main
Jun 4, 2026
Merged

feat: add java-21-sample with virtual threads and SSL health indicator#83
dingmeng-xue merged 1 commit into
Azure-Samples:mainfrom
dingmeng-xue:main

Conversation

@dingmeng-xue

Copy link
Copy Markdown
Contributor

Summary

Adds a new java-21-sample module to showcase Java 21 LTS features on Azure Spring Apps, modelled after the existing java-17-sample.

What's Changed

New module: java-21-sample

Stack

  • Java 21, Spring Boot 3.4.1, Spring Cloud 2024.0.0
  • maven-compiler-plugin 3.13.0 and maven-resources-plugin 3.3.1 pinned in <pluginManagement> to suppress plugin-validation warnings

Java 21 language features demonstrated

  • Virtual threadsspring.threads.virtual.enabled=true enables Project Loom for improved concurrency
  • RecordsGreeting record used as an immutable data carrier in HelloController
  • Switch expressions — LTS tier detection in GET /java-version
  • Text blocks — response body in GET /java-version
  • Pattern-matching instanceof — used in SslController when iterating keystore entries

SSL Health Indicator (Spring Boot 3.4)

  • SSL bundle demo configured via spring.ssl.bundle.jks.* with a self-signed JKS keystore
  • management.health.ssl.enabled=true activates SslHealthIndicator
  • management.health.ssl.certificate-validity-warning-threshold=P30D raises WARNING when the cert expires within 30 days
  • GET /actuator/health/ssl — actuator-native health status (UP / WARNING / DOWN)
  • GET /ssl/info — human-readable HTML table of certificate metadata (alias, subject, issuer, validity dates, serial)

Deployment

  • Standard Plan: --runtime-version Java_21
  • Enterprise Plan: --source-path . --build-env BP_JVM_VERSION=21.*

Files Added

File Purpose
pom.xml Project build, Java 21 compiler, Spring Boot 3.4.1 / Spring Cloud 2024.0.0
Java21SampleApplication.java Spring Boot entry point
HelloController.java Greeting, java-version, and memory endpoints
EurekaController.java Eureka service registry inspection
SslController.java SSL bundle certificate metadata endpoint
application.properties SSL bundle config, health indicator settings, virtual threads
ssl/demo.jks Self-signed demo keystore (RSA-2048, 365-day validity)
README.md Overview, endpoint table, local-dev and deployment instructions

@dingmeng-xue
dingmeng-xue merged commit f200a16 into Azure-Samples:main Jun 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants