Allow also URLs with additional parameters#118
Open
kamir wants to merge 1 commit intoapache:masterfrom
Open
Conversation
Not all URLs end with JAR or ZIP, e.g., if we load content from an HTTPFS Service.
Examples for testing: (a,c,d work as expeced) (b => more logic needed to create a JAR name from this URL)
import java.io.{File, PrintStream}
import java.net.URL
import java.nio.file.{Files, Paths}
def getFileFromLocation(location: String): String = {
val url = new URL(location)
val file = url.getFile.split("/")
if (file.length > 0) {
if ( file.last.contains('?') ) {
file.last.split('?')(0)
}
else {
file.last
}
} else {
""
}
}
val fnA = "http://cdsw-mk4-1.gce.cloudera.com:8888/filebrowser/download=/user/systest/TOOLBOX/SparkShellUtilities.jar?user.name=123"
val a = getFileFromLocation(fnA)
a
val fnB = "https://oss.sonatype.org/service/local/artifact/maven/content?r=snapshots&g=org.gephi&a=gephi-toolkit&v=0.9.2-SNAPSHOT&c=all"
val b = getFileFromLocation(fnB)
b
val fnC = "http://cdsw-mk4-1.gce.cloudera.com:8888/filebrowser/download=/user/systest/TOOLBOX/SparkShellUtilities.jar"
val c = getFileFromLocation(fnC)
c
val fnD = "http://cdsw-mk4-1.gce.cloudera.com:8888/filebrowser/download=/user/systest/TOOLBOX/SparkShellUtilities.jar?user.name=123&doas=123456"
val d = getFileFromLocation(fnD)
d
Member
|
@kamir Could you please update AddJarSpec.scala with some tests that validate your additions. |
Member
|
Welcome @kamir! Thanks for finding this bug and working on a fix. Check out this documentation on URL https://docs.oracle.com/javase/7/docs/api/java/net/URL.html#getFile(), I think a simpler fix is to just change the "getFile" part above to "getPath" |
Member
|
@kamir Could you please rebase and add a test case to the enhancements you are making. |
Author
|
My plan is to work on this during the next week.
Best wishes,
Mirko
…On Sat, Aug 19, 2017 at 6:21 AM, Luciano Resende ***@***.***> wrote:
@kamir <https://github.com/kamir> Could you please rebase and add a test
case to the enhancements you are making.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#118 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABLwIlZ8CxINgXlYMxqe2cQQ77aecMaVks5sZmKygaJpZM4Mml0G>
.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not all URLs end with JAR or ZIP, e.g., if we load content from an HTTPFS Service.
Examples for testing: (a,c,d work as expeced) (b => more logic needed to create a JAR name from this URL)
import java.io.{File, PrintStream}
import java.net.URL
import java.nio.file.{Files, Paths}
def getFileFromLocation(location: String): String = {
val url = new URL(location)
val file = url.getFile.split("/")
if (file.length > 0) {
if ( file.last.contains('?') ) {
file.last.split('?')(0)
}
else {
file.last
}
} else {
""
}
}
val fnA = "http://cdsw-mk4-1.gce.cloudera.com:8888/filebrowser/download=/user/systest/TOOLBOX/SparkShellUtilities.jar?user.name=123"
val a = getFileFromLocation(fnA)
a
val fnB = "https://oss.sonatype.org/service/local/artifact/maven/content?r=snapshots&g=org.gephi&a=gephi-toolkit&v=0.9.2-SNAPSHOT&c=all"
val b = getFileFromLocation(fnB)
b
val fnC = "http://cdsw-mk4-1.gce.cloudera.com:8888/filebrowser/download=/user/systest/TOOLBOX/SparkShellUtilities.jar"
val c = getFileFromLocation(fnC)
c
val fnD = "http://cdsw-mk4-1.gce.cloudera.com:8888/filebrowser/download=/user/systest/TOOLBOX/SparkShellUtilities.jar?user.name=123&doas=123456"
val d = getFileFromLocation(fnD)
d