-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-6568] spark-shell.cmd --jars option does not accept the jar that has space in its path #5447
Changes from 7 commits
c7ba6a7
649da82
93c3c40
10f1c73
45946ee
7019a8a
2c62e3b
016128d
84c33d0
e03f289
1784239
ed46047
3f9a188
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1659,9 +1659,14 @@ private[spark] object Utils extends Logging { | |
val windowsDrive = "([a-zA-Z])".r | ||
|
||
/** | ||
* Format a Windows path such that it can be safely passed to a URI. | ||
* Format a path such that it can be safely passed to a URI. | ||
*/ | ||
def formatWindowsPath(path: String): String = path.replace("\\", "/") | ||
def formatPath(path: String, windows: Boolean): String = { | ||
val formatted = path.replace(" ", "%20") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is OK for now and solves the immediate problem. I wonder if we will need to do more complete URI escaping later -- although, it's not clear what URI scheme we assume anyway. LGTM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of this, how about:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When path contains There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
... is technically correct, if this is what you mean. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean we should assume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @steveloughran I think the issue is that we don't start with a
This still seems like the way to go as far as I can tell. |
||
|
||
// In Windows, the file separator is a backslash, but this is inconsistent with the URI format | ||
if (windows) formatted.replace("\\", "/") else formatted | ||
} | ||
|
||
/** | ||
* Indicates whether Spark is currently running unit tests. | ||
|
@@ -1762,9 +1767,8 @@ private[spark] object Utils extends Logging { | |
*/ | ||
def resolveURI(path: String, testWindows: Boolean = false): URI = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// In Windows, the file separator is a backslash, but this is inconsistent with the URI format | ||
val windows = isWindows || testWindows | ||
val formattedPath = if (windows) formatWindowsPath(path) else path | ||
val formattedPath = formatPath(path, windows) | ||
|
||
val uri = new URI(formattedPath) | ||
if (uri.getPath == null) { | ||
|
@@ -1801,7 +1805,7 @@ private[spark] object Utils extends Logging { | |
Array.empty | ||
} else { | ||
paths.split(",").filter { p => | ||
val formattedPath = if (windows) formatWindowsPath(p) else p | ||
val formattedPath = formatPath(p, windows) | ||
val uri = new URI(formattedPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use |
||
Option(uri.getScheme).getOrElse("file") match { | ||
case windowsDrive(d) if windows => false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not your fault, but I'm not sure this will ever match anything, since the match is on the URI's scheme. But probably doesn't hurt to leave here if you don't want to double-check that. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,7 +206,8 @@ class SparkILoop( | |
// e.g. file:/C:/my/path.jar -> C:/my/path.jar | ||
SparkILoop.getAddedJars.map { jar => new URI(jar).getPath.stripPrefix("/") } | ||
} else { | ||
SparkILoop.getAddedJars | ||
// We need new URI(jar).getPath here for the case that `jar` includes encoded white space (%20). | ||
SparkILoop.getAddedJars.map { jar => new URI(jar).getPath} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the scala-2.11 REPL need the same treatment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scala-2.11 REPL seems not have the equivelent code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: space before |
||
} | ||
// work around for Scala bug | ||
val totalClassPath = addedJars.foldLeft( | ||
|
@@ -1109,7 +1110,7 @@ object SparkILoop extends Logging { | |
if (settings.classpath.isDefault) | ||
settings.classpath.value = sys.props("java.class.path") | ||
|
||
getAddedJars.foreach(settings.classpath.append(_)) | ||
getAddedJars.map(jar => new URI(jar).getPath).foreach(settings.classpath.append(_)) | ||
|
||
repl process settings | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only use of
formatPath
leftover and it doesn't feel necessary. Instead, how about:Then you can remove
Utils.formatPath
. Maybe evenUtils.windowsDrive
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. I'll try to remove them.