Skip to content

Commit

Permalink
Replace URL() calls to URI.toURL() as it is deprecated since Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Jul 15, 2024
1 parent 6bef7af commit 96a55b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/mcdev.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import java.net.HttpURLConnection
import java.net.URI
import java.net.URL
import java.util.Properties
import java.util.zip.ZipFile
Expand Down Expand Up @@ -94,7 +95,7 @@ tasks.register("resolveIntellijLibSources") {
val groupPath = dep.groupId.replace('.', '/')
val (_, artifact, ver) = dep
val url = "https://repo.maven.apache.org/maven2/$groupPath/$artifact/$ver/$artifact-$ver-sources.jar"
return@filter with(URL(url).openConnection() as HttpURLConnection) {
return@filter with(URI.create(url).toURL().openConnection() as HttpURLConnection) {
try {
requestMethod = "GET"
val code = responseCode
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/util/HttpConnectionFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ package com.demonwav.mcdev.util

import com.intellij.util.net.HttpConfigurable
import java.net.HttpURLConnection
import java.net.URL
import java.net.URI

sealed class HttpConnectionFactory {
open fun openHttpConnection(url: String) = URL(url).openConnection() as HttpURLConnection
open fun openHttpConnection(url: String) = URI.create(url).toURL().openConnection() as HttpURLConnection
}

object ProxyHttpConnectionFactory : HttpConnectionFactory() {
Expand Down

0 comments on commit 96a55b2

Please sign in to comment.