Address deprecation warning

This commit is contained in:
Alexandre Archambault 2020-09-15 11:00:08 +02:00
parent 90f44bc5cc
commit f8c75d7033
1 changed files with 9 additions and 11 deletions

View File

@ -3,7 +3,7 @@ package lmcoursier.internal
import java.io.{File, FileNotFoundException, IOException} import java.io.{File, FileNotFoundException, IOException}
import java.net.{HttpURLConnection, URL, URLConnection} import java.net.{HttpURLConnection, URL, URLConnection}
import coursier.cache.{CacheUrl, FileCache} import coursier.cache.{ConnectionBuilder, FileCache}
import coursier.core._ import coursier.core._
import coursier.util.{Artifact, EitherT, Monad} import coursier.util.{Artifact, EitherT, Monad}
@ -54,16 +54,14 @@ object TemporaryInMemoryRepository {
var conn: URLConnection = null var conn: URLConnection = null
try { try {
conn = CacheUrl.urlConnection( conn = ConnectionBuilder(url.toURI.toASCIIString)
url.toString, .withFollowHttpToHttpsRedirections(cacheOpt.fold(false)(_.followHttpToHttpsRedirections))
None, .withFollowHttpsToHttpRedirections(cacheOpt.fold(false)(_.followHttpsToHttpRedirections))
followHttpToHttpsRedirections = cacheOpt.fold(false)(_.followHttpToHttpsRedirections), .withSslSocketFactoryOpt(cacheOpt.flatMap(_.sslSocketFactoryOpt))
followHttpsToHttpRedirections = cacheOpt.fold(false)(_.followHttpsToHttpRedirections), .withHostnameVerifierOpt(cacheOpt.flatMap(_.hostnameVerifierOpt))
sslSocketFactoryOpt = cacheOpt.flatMap(_.sslSocketFactoryOpt), .withMethod("HEAD")
hostnameVerifierOpt = cacheOpt.flatMap(_.hostnameVerifierOpt), .withMaxRedirectionsOpt(cacheOpt.flatMap(_.maxRedirections))
method = "HEAD", .connection()
maxRedirectionsOpt = cacheOpt.flatMap(_.maxRedirections)
)
// Even though the finally clause handles this too, this has to be run here, so that we return Some(true) // Even though the finally clause handles this too, this has to be run here, so that we return Some(true)
// iff this doesn't throw. // iff this doesn't throw.
conn.getInputStream.close() conn.getInputStream.close()