dongjoon-hyun commented on a change in pull request #26530: [SPARK-25694][SQL] 
Add a config for `URL.setURLStreamHandlerFactory`
URL: https://github.com/apache/spark/pull/26530#discussion_r347168170
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/internal/SharedState.scala
 ##########
 @@ -191,11 +194,15 @@ private[sql] class SharedState(
 }
 
 object SharedState extends Logging {
-  try {
-    URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory())
-  } catch {
-    case e: Error =>
-      logWarning("URL.setURLStreamHandlerFactory failed to set 
FsUrlStreamHandlerFactory")
+  private def setFsUrlStreamHandlerFactory(conf: SparkConf): Unit = {
+    if (conf.get(DEFAULT_URL_STREAM_HANDLER_FACTORY_ENABLED)) {
+      try {
+        URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory())
 
 Review comment:
   The following is `setURLStreamHandlerFactory` of `URL.java`. Java already 
tracks it with `factory` variable. I don't think our provide any benefit. So, 
invoking `setURLStreamHandlerFactory` multiple times is okay.
   ```
       public static void setURLStreamHandlerFactory(URLStreamHandlerFactory 
fac) {
           synchronized (streamHandlerLock) {
               if (factory != null) {
                   throw new Error("factory already defined");
               }
               SecurityManager security = System.getSecurityManager();
               if (security != null) {
                   security.checkSetFactory();
               }
               handlers.clear();
               factory = fac;
           }
       }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to