grpc / grpc-kotlin

Kotlin gRPC implementation. HTTP/2 based RPC
https://grpc.io/docs/languages/kotlin
Apache License 2.0
1.2k stars 165 forks source link

java 20 / 21 - constructor URL(String!) is deprecated #626

Open wavedeck opened 2 months ago

wavedeck commented 2 months ago

I was trying to locally build grpc-kotlin because v1.4.2 didn't release yet on maven central repository but i wanted to test it. while I did, I have noticed that gradle logged a warning during the first sync that using java.net.URL(string) was deprecated.

As i have tracked down the source of this deprecation warning, i noticed that it is coming from the build.gradle.kts of the stub sub-project. Apparently, java.net.URL was deprecated in Java 20, which is the reason i got this warning when trying to build it using the latest LTS release (21.0.4)

I have researched the deprecation warning as it was documented and deemed as unsafe on the Java 21 specification.

The easy and straight forward fix is to replace java.net.URL(string) with java.net.URI(string).toURL() in the gradle project file for the stub sub-project.

This change has no effect on the functionality or backwards compatibility as .toURL() already existed back in Java 8