Skip to content

Commit

Permalink
remove usage of ParseUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bli committed Nov 21, 2023
1 parent 84e12fe commit efacc14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
13 changes: 2 additions & 11 deletions src/main/scala/com/snowflake/snowpark/internal/UDFClassPath.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.JsonNode
import java.io.File
import java.net.{URI, URLClassLoader}
import com.snowflake.snowpark.Session
import sun.net.www.ParseUtil

object UDFClassPath extends Logging {

Expand Down Expand Up @@ -94,13 +93,7 @@ object UDFClassPath extends Logging {
if (path.contains(":")) {
path = path.substring(path.indexOf(":") + 1)
}
/*
* The URL in class loader is encoded, so we have to decode it to read the
* local file.
*/
path = ParseUtil.decode(path)
// Creating a File fixes the separator based on OS
new File(path).getPath
new URI(path).getPath
}
}

Expand All @@ -111,9 +104,7 @@ object UDFClassPath extends Logging {
* The URL in CodeSource location is encoded, so we have to decode it to read the
* local file.
*/
val parsed = ParseUtil.decode(codeSource.getLocation.getPath)
// Creating a File fixes the separator based on OS
Some(new File(parsed).getPath)
Some(new URI(codeSource.getLocation.getPath).getPath)
} else {
None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.snowflake.snowpark.internal.Utils.clientPackageName
import java.io.{BufferedOutputStream, File, FileOutputStream}
import java.nio.file.{Files, NoSuchFileException}
import com.snowflake.snowpark.internal.{JavaUtils, UDFClassPath}
import sun.net.www.ParseUtil

import scala.reflect.internal.util.BatchSourceFile
import scala.reflect.io.{AbstractFile, VirtualDirectory}
Expand All @@ -23,11 +22,6 @@ class UDFRegistrationSuite extends SNTestBase with FileUtils {
session.runQuery(s"create or replace temporary stage $tempStage")
}

test("Test URL encoding") {
val inputs = Seq("dbiufwhronr==", "fdeswfirn--", "bsdij++", "sb#i", "bxsj%i@9h(nb)")
inputs.foreach(str => assert(ParseUtil.decode(ParseUtil.encodePath(str)) == str))
}

test("Test that jar files are uploaded to stage correctly") {
val udfRegistrar = new UDFRegistration(session)
val classDirs = UDFClassPath.classDirs(session).toList
Expand Down

0 comments on commit efacc14

Please sign in to comment.