From f8c75d70334cd97fd64321c5882ea073f3293e22 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 15 Sep 2020 11:00:08 +0200 Subject: [PATCH] Address deprecation warning --- .../TemporaryInMemoryRepository.scala | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala b/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala index bf67a9681..a7c35dad4 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala @@ -3,7 +3,7 @@ package lmcoursier.internal import java.io.{File, FileNotFoundException, IOException} import java.net.{HttpURLConnection, URL, URLConnection} -import coursier.cache.{CacheUrl, FileCache} +import coursier.cache.{ConnectionBuilder, FileCache} import coursier.core._ import coursier.util.{Artifact, EitherT, Monad} @@ -54,16 +54,14 @@ object TemporaryInMemoryRepository { var conn: URLConnection = null try { - conn = CacheUrl.urlConnection( - url.toString, - None, - followHttpToHttpsRedirections = cacheOpt.fold(false)(_.followHttpToHttpsRedirections), - followHttpsToHttpRedirections = cacheOpt.fold(false)(_.followHttpsToHttpRedirections), - sslSocketFactoryOpt = cacheOpt.flatMap(_.sslSocketFactoryOpt), - hostnameVerifierOpt = cacheOpt.flatMap(_.hostnameVerifierOpt), - method = "HEAD", - maxRedirectionsOpt = cacheOpt.flatMap(_.maxRedirections) - ) + conn = ConnectionBuilder(url.toURI.toASCIIString) + .withFollowHttpToHttpsRedirections(cacheOpt.fold(false)(_.followHttpToHttpsRedirections)) + .withFollowHttpsToHttpRedirections(cacheOpt.fold(false)(_.followHttpsToHttpRedirections)) + .withSslSocketFactoryOpt(cacheOpt.flatMap(_.sslSocketFactoryOpt)) + .withHostnameVerifierOpt(cacheOpt.flatMap(_.hostnameVerifierOpt)) + .withMethod("HEAD") + .withMaxRedirectionsOpt(cacheOpt.flatMap(_.maxRedirections)) + .connection() // 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. conn.getInputStream.close()