@@ -340,8 +340,8 @@ private[spark] object Utils extends Logging {
340
340
val targetFile = new File (targetDir, filename)
341
341
val uri = new URI (url)
342
342
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" ) =>
345
345
logInfo(" Fetching " + url + " to " + tempFile)
346
346
347
347
var uc : URLConnection = null
@@ -374,7 +374,7 @@ private[spark] object Utils extends Logging {
374
374
}
375
375
}
376
376
Files .move(tempFile, targetFile)
377
- case " file" | null =>
377
+ case Some ( " file" ) | None =>
378
378
// In the case of a local file, copy the local file to the target directory.
379
379
// Note the difference between uri vs url.
380
380
val sourceFile = if (uri.isAbsolute) new File (uri) else new File (url)
@@ -403,7 +403,7 @@ private[spark] object Utils extends Logging {
403
403
logInfo(" Copying " + sourceFile.getAbsolutePath + " to " + targetFile.getAbsolutePath)
404
404
Files .copy(sourceFile, targetFile)
405
405
}
406
- case _ =>
406
+ case Some (other) =>
407
407
// Use the Hadoop filesystem library, which supports file://, hdfs://, s3://, and others
408
408
val fs = getHadoopFileSystem(uri, hadoopConf)
409
409
val in = fs.open(new Path (uri))
@@ -1368,16 +1368,17 @@ private[spark] object Utils extends Logging {
1368
1368
if (uri.getPath == null ) {
1369
1369
throw new IllegalArgumentException (s " Given path is malformed: $uri" )
1370
1370
}
1371
- uri.getScheme match {
1372
- case windowsDrive(d) if windows =>
1371
+
1372
+ Option (uri.getScheme) match {
1373
+ case Some (windowsDrive(d)) if windows =>
1373
1374
new URI (" file:/" + uri.toString.stripPrefix(" /" ))
1374
- case null =>
1375
+ case None =>
1375
1376
// Preserve fragments for HDFS file name substitution (denoted by "#")
1376
1377
// For instance, in "abc.py#xyz.py", "xyz.py" is the name observed by the application
1377
1378
val fragment = uri.getFragment
1378
1379
val part = new File (uri.getPath).toURI
1379
1380
new URI (part.getScheme, part.getPath, fragment)
1380
- case _ =>
1381
+ case Some (other) =>
1381
1382
uri
1382
1383
}
1383
1384
}
@@ -1399,10 +1400,11 @@ private[spark] object Utils extends Logging {
1399
1400
} else {
1400
1401
paths.split(" ," ).filter { p =>
1401
1402
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
1406
1408
}
1407
1409
}
1408
1410
}
0 commit comments