11package agent
22
33import java .io .FileNotFoundException
4- import java .net .{ URI , URL , URLConnection , URLStreamHandler }
4+ import java .net .URI
55
66import collectors .Instance
77import conf .{AWS , PrismConfiguration }
@@ -206,17 +206,6 @@ case class JsonOrigin(
206206 crawlRate : Map [String , CrawlRate ]
207207) extends Origin
208208 with Logging {
209- private val classpathHandler = new URLStreamHandler {
210- override def openConnection (u : URL ): URLConnection = {
211- Option (getClass.getResource(u.getPath))
212- .map(_.openConnection())
213- .getOrElse {
214- throw new FileNotFoundException (
215- " %s not found on classpath" format u.getPath
216- )
217- }
218- }
219- }
220209
221210 def credsFromS3Url (url : URI ): AwsCredentialsProvider = {
222211 Option (url.getUserInfo) match {
@@ -237,10 +226,11 @@ case class JsonOrigin(
237226 url.replace(" %resource%" , resource.name)
238227 ) match {
239228 case classPathLocation if classPathLocation.getScheme == " classpath" =>
240- Source .fromURL(
241- new URL (null , classPathLocation.toString, classpathHandler),
242- " utf-8"
243- )
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" )
244234 case s3Location if s3Location.getScheme == " s3" =>
245235 val s3Client = S3Client .builder
246236 .credentialsProvider(credsFromS3Url(s3Location))
0 commit comments