File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/scala/org/apache/spark/deploy
test/scala/org/apache/spark/deploy Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1717
1818package org .apache .spark .deploy
1919
20+ import java .net .{URI , URISyntaxException }
21+
2022import scala .collection .mutable .ListBuffer
2123
2224import org .apache .log4j .Level
@@ -114,5 +116,12 @@ private[spark] class ClientArguments(args: Array[String]) {
114116}
115117
116118object ClientArguments {
117- def isValidJarUrl (s : String ): Boolean = s.matches(" (.+):(.+)jar" )
119+ def isValidJarUrl (s : String ): Boolean = {
120+ try {
121+ val uri = new URI (s)
122+ uri.getScheme != null && uri.getAuthority != null && s.endsWith(" jar" )
123+ } catch {
124+ case _ : URISyntaxException => false
125+ }
126+ }
118127}
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ class ClientSuite extends FunSuite with Matchers {
2929 ClientArguments .isValidJarUrl(" hdfs://someHost:1234/foo" ) should be (false )
3030 ClientArguments .isValidJarUrl(" /missing/a/protocol/jarfile.jar" ) should be (false )
3131 ClientArguments .isValidJarUrl(" not-even-a-path.jar" ) should be (false )
32+
33+ // No authority
34+ ClientArguments .isValidJarUrl(" hdfs:someHost:1234/jarfile.jar" ) should be (false )
35+
36+ // Invalid syntax
37+ ClientArguments .isValidJarUrl(" hdfs:" )should be (false )
3238 }
3339
3440}
You can’t perform that action at this time.
0 commit comments