@@ -340,8 +340,8 @@ private[spark] object Utils extends Logging {
340340 val targetFile = new File (targetDir, filename)
341341 val uri = new URI (url)
342342 val fileOverwrite = conf.getBoolean(" spark.files.overwrite" , defaultValue = false )
343- uri.getScheme match {
344- case " http" | " https" | " ftp" =>
343+ Option ( uri.getScheme) match {
344+ case Some ( " http" ) | Some ( " https" ) | Some ( " ftp" ) =>
345345 logInfo(" Fetching " + url + " to " + tempFile)
346346
347347 var uc : URLConnection = null
@@ -374,7 +374,7 @@ private[spark] object Utils extends Logging {
374374 }
375375 }
376376 Files .move(tempFile, targetFile)
377- case " file" | null =>
377+ case Some ( " file" ) | None =>
378378 // In the case of a local file, copy the local file to the target directory.
379379 // Note the difference between uri vs url.
380380 val sourceFile = if (uri.isAbsolute) new File (uri) else new File (url)
@@ -403,7 +403,7 @@ private[spark] object Utils extends Logging {
403403 logInfo(" Copying " + sourceFile.getAbsolutePath + " to " + targetFile.getAbsolutePath)
404404 Files .copy(sourceFile, targetFile)
405405 }
406- case _ =>
406+ case Some (other) =>
407407 // Use the Hadoop filesystem library, which supports file://, hdfs://, s3://, and others
408408 val fs = getHadoopFileSystem(uri, hadoopConf)
409409 val in = fs.open(new Path (uri))
@@ -1368,16 +1368,17 @@ private[spark] object Utils extends Logging {
13681368 if (uri.getPath == null ) {
13691369 throw new IllegalArgumentException (s " Given path is malformed: $uri" )
13701370 }
1371- uri.getScheme match {
1372- case windowsDrive(d) if windows =>
1371+
1372+ Option (uri.getScheme) match {
1373+ case Some (windowsDrive(d)) if windows =>
13731374 new URI (" file:/" + uri.toString.stripPrefix(" /" ))
1374- case null =>
1375+ case None =>
13751376 // Preserve fragments for HDFS file name substitution (denoted by "#")
13761377 // For instance, in "abc.py#xyz.py", "xyz.py" is the name observed by the application
13771378 val fragment = uri.getFragment
13781379 val part = new File (uri.getPath).toURI
13791380 new URI (part.getScheme, part.getPath, fragment)
1380- case _ =>
1381+ case Some (other) =>
13811382 uri
13821383 }
13831384 }
@@ -1399,10 +1400,11 @@ private[spark] object Utils extends Logging {
13991400 } else {
14001401 paths.split(" ," ).filter { p =>
14011402 val formattedPath = if (windows) formatWindowsPath(p) else p
1402- new URI (formattedPath).getScheme match {
1403- case windowsDrive(d) if windows => false
1404- case " local" | " file" | null => false
1405- case _ => true
1403+ val uri = new URI (formattedPath)
1404+ Option (uri.getScheme) match {
1405+ case Some (windowsDrive(d)) if windows => false
1406+ case Some (" local" ) | Some (" file" ) | None => false
1407+ case Some (other) => true
14061408 }
14071409 }
14081410 }
0 commit comments