Skip to content

Upgrade to Java 21#1101

Merged
jorgeazevedo merged 7 commits intomainfrom
ja-java-upgrade
Mar 20, 2026
Merged

Upgrade to Java 21#1101
jorgeazevedo merged 7 commits intomainfrom
ja-java-upgrade

Conversation

@jorgeazevedo
Copy link
Copy Markdown
Contributor

@jorgeazevedo jorgeazevedo commented Feb 13, 2026

What does this change?

Upgrades Java runtime from 11 to 21.

This code relies on using java.net.URL constructors new URL() which has been deprecated in Java 20.

This constructor is used to to be able to call Source.fromUrl on a classpath:/ URL. This was done by instantiating a new URL object on classpath:/ directly, which the URL constructor does not support, so it required writing a custom UrlStreamHandler to load it from the file system.

Before patch

Source.fromURL(
  new URL(null, classPathLocation.toString, classpathHandler), 
  // toString() => "classpath:/test-data.json"
  "utf-8"
 )

The alternative proposed here is to just call getClass.getResource(path) and get a natively supported file:/ URL object

After patch

val resourceURL = Option(getClass.getResource(path)).getOrElse {
  throw new FileNotFoundException(s"$path not found on classpath")
}
Source.fromURL(
  resourceURL, 
  // toString() "file:/~/code/guardian/prism/target/scala-2.13/classes/test-data.json"
  "utf-8") 

How has this change been tested?

Beyond the local execution, I've deployed it to CODE and as far as I can tell the application is running properly and able to populate the different endpoints.

@jorgeazevedo jorgeazevedo added the maintenance Departmental tracking: maintenance work, not a fix or a feature label Feb 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 13, 2026

This comment was marked as resolved.

@jorgeazevedo jorgeazevedo changed the title chore: Upgrade to Java 21 Upgrade to Java 21 Mar 12, 2026
@jorgeazevedo jorgeazevedo marked this pull request as ready for review March 13, 2026 10:58
@jorgeazevedo jorgeazevedo added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 3c6671c Mar 20, 2026
8 checks passed
@jorgeazevedo jorgeazevedo deleted the ja-java-upgrade branch March 20, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants