11package agent
22
33import java .io .FileNotFoundException
4- import java .net .{URI , URL , URLConnection , URLStreamHandler }
5- import scala .annotation .nowarn
4+ import java .net .URI
65
76import collectors .Instance
87import conf .{AWS , PrismConfiguration }
@@ -207,17 +206,6 @@ case class JsonOrigin(
207206 crawlRate : Map [String , CrawlRate ]
208207) extends Origin
209208 with Logging {
210- private val classpathHandler = new URLStreamHandler {
211- override def openConnection (u : URL ): URLConnection = {
212- Option (getClass.getResource(u.getPath))
213- .map(_.openConnection())
214- .getOrElse {
215- throw new FileNotFoundException (
216- " %s not found on classpath" format u.getPath
217- )
218- }
219- }
220- }
221209
222210 def credsFromS3Url (url : URI ): AwsCredentialsProvider = {
223211 Option (url.getUserInfo) match {
@@ -234,15 +222,15 @@ case class JsonOrigin(
234222 }
235223
236224 def data (resource : ResourceType ): JsValue = {
237- @ nowarn(" cat=deprecation" )
238225 val source : Source = new URI (
239226 url.replace(" %resource%" , resource.name)
240227 ) match {
241228 case classPathLocation if classPathLocation.getScheme == " classpath" =>
242- Source .fromURL(
243- new URL (null , classPathLocation.toString, classpathHandler),
244- " utf-8"
245- )
229+ val path = classPathLocation.getPath
230+ val resourceURL = Option (getClass.getResource(path)).getOrElse {
231+ throw new FileNotFoundException (s " $path not found on classpath " )
232+ }
233+ Source .fromURL(resourceURL, " utf-8" )
246234 case s3Location if s3Location.getScheme == " s3" =>
247235 val s3Client = S3Client .builder
248236 .credentialsProvider(credsFromS3Url(s3Location))
0 commit comments