Skip to content

chore: jdk 21 support#953

Merged
sbansla merged 4 commits intomainfrom
jdk-21-support-21-apr
Apr 21, 2026
Merged

chore: jdk 21 support#953
sbansla merged 4 commits intomainfrom
jdk-21-support-21-apr

Conversation

@sbansla
Copy link
Copy Markdown
Contributor

@sbansla sbansla commented Apr 21, 2026

  • Add JDK 21 build and test support while maintaining JDK 8 runtime compatibility (-source 8 -target 8)
  • Replace deprecated io.jsonwebtoken.SignatureAlgorithm enum with io.jsonwebtoken.security.SecureDigestAlgorithm from jjwt 0.12.x across all public APIs (Jwt, ValidationClient, ValidationInterceptor, ValidationToken)
  • Replace deprecated URLEncodedUtils with URIBuilder in RequestValidator (internal, no public API impact)
  • Add upgrade guide to UPGRADE.md documenting breaking changes, migration steps, and algorithm constant mapping (SignatureAlgorithm.X → Jwts.SIG.X)

Breaking Changes

  • Public API parameter type changed from SignatureAlgorithm to SecureDigestAlgorithm in Jwt, ValidationClient, ValidationInterceptor, and ValidationToken
  • Customers passing explicit algorithm constants must migrate: SignatureAlgorithm.RS256 → Jwts.SIG.RS256
  • Customers using default constructors (without algorithm parameter) are not affected

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds JDK 21 build/test support while keeping JDK 8 bytecode compatibility, and updates JWT-related APIs to use jjwt 0.12.x SecureDigestAlgorithm/Jwts.SIG.* instead of deprecated SignatureAlgorithm.

Changes:

  • Add Maven profiles/properties to support testing on JDK 8 and JDK 11+ (incl. 21) with appropriate Surefire configuration.
  • Migrate public JWT/validation APIs and usages from SignatureAlgorithm to SecureDigestAlgorithm with Jwts.SIG.* constants.
  • Replace deprecated URLEncodedUtils with URIBuilder in RequestValidator and update docs/tests accordingly.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/test/java/com/twilio/jwt/validation/ValidationTokenTest.java Updates tests to use SecureDigestAlgorithm and Jwts.SIG.* constants.
src/test/java/com/twilio/http/RequestTest.java Loosens URI error message assertion for cross-JDK variance.
src/test/java/com/twilio/compliance/ComplianceTest.java Updates EqualsVerifier usage (suppresses BigDecimal equality warning).
src/main/java/com/twilio/security/RequestValidator.java Switches query parsing from URLEncodedUtils to URIBuilder.
src/main/java/com/twilio/jwt/validation/ValidationToken.java Updates supported algorithm handling and public API signatures to SecureDigestAlgorithm.
src/main/java/com/twilio/jwt/taskrouter/TaskRouterCapability.java Replaces SignatureAlgorithm.HS256 with Jwts.SIG.HS256.
src/main/java/com/twilio/jwt/client/ClientCapability.java Replaces SignatureAlgorithm.HS256 with Jwts.SIG.HS256.
src/main/java/com/twilio/jwt/accesstoken/AccessToken.java Replaces SignatureAlgorithm.HS256 with Jwts.SIG.HS256.
src/main/java/com/twilio/jwt/Jwt.java Refactors algorithm typing and signWith usage for jjwt 0.12.x APIs.
src/main/java/com/twilio/http/ValidationInterceptor.java Updates constructor/API to accept SecureDigestAlgorithm and defaults to Jwts.SIG.RS256.
src/main/java/com/twilio/http/ValidationClient.java Updates constructors/API to accept SecureDigestAlgorithm and defaults to Jwts.SIG.RS256.
src/main/java/com/twilio/example/ValidationExample.java Updates example to use Jwts.SIG.PS256.
pom.xml Adds JDK-specific profiles, upgrades plugin versions, and parameterizes dependency/plugin versions.
UPGRADE.md Adds 11.x → 12.x upgrade notes and algorithm mapping guidance.
.gitignore Ignores local Claude-related files.
.github/workflows/test-and-deploy.yml Extends CI matrix to include Java 21.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Request request = new Request(HttpMethod.DELETE, "http://{");
ApiException e = assertThrows(ApiException.class, request::constructURL);
assertEquals("Bad URI: Illegal character in authority at index 7: http://{", e.getMessage());
assertTrue(e.getMessage().startsWith("Bad UR"));
Comment on lines 247 to 249
public Builder algorithm(SecureDigestAlgorithm<? extends Key, ?> algorithm) {
if (!supportedAlgorithms.contains(algorithm)) {
throw new IllegalArgumentException("Not supported!");
@@ -49,7 +50,7 @@ public ValidationInterceptor(String accountSid, String credentialSid, String sig
* @param algorithm Client validaiton algorithm
Comment on lines 3 to +6
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.security.MacAlgorithm;
import io.jsonwebtoken.security.SecureDigestAlgorithm;
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sbansla sbansla merged commit 975dd6e into main Apr 21, 2026
20 of 21 checks passed
@sbansla sbansla deleted the jdk-21-support-21-apr branch April 21, 2026 16:50
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.

3 participants