You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Marco Tulio Avila Cerón (JIRA)" <ji...@apache.org> on 2014/06/14 09:27:02 UTC

[jira] [Issue Comment Deleted] (CASSANDRA-7398) -Dcassandra.config= needs file:///

     [ https://issues.apache.org/jira/browse/CASSANDRA-7398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Tulio Avila Cerón updated CASSANDRA-7398:
-----------------------------------------------

    Comment: was deleted

(was: Index: src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/org/apache/cassandra/config/YamlConfigurationLoader.java	(revision 305132946d20c7c2e81f2eb80da50f7131031061)
+++ src/java/org/apache/cassandra/config/YamlConfigurationLoader.java	(revision )
@@ -19,8 +19,8 @@
 
 import java.beans.IntrospectionException;
 import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.HashSet;
 import java.util.Map;
@@ -45,6 +45,7 @@
     private static final Logger logger = LoggerFactory.getLogger(YamlConfigurationLoader.class);
 
     private final static String DEFAULT_CONFIGURATION = "cassandra.yaml";
+    private static final String FILE_PREFIX = "file:///";
 
     /**
      * Inspect the classpath to find storage configuration file
@@ -58,17 +59,39 @@
         URL url;
         try
         {
-            url = new URL(configUrl);
-            url.openStream().close(); // catches well-formed but bogus URLs
+            url = getUrl(configUrl);
         }
         catch (Exception e)
         {
             ClassLoader loader = DatabaseDescriptor.class.getClassLoader();
             url = loader.getResource(configUrl);
             if (url == null)
-                throw new ConfigurationException("Cannot locate " + configUrl);
+            {
+                final String message = String.format("Cannot locate %s", configUrl);
+                if (!configUrl.startsWith(FILE_PREFIX))
+                {
+                    configUrl = FILE_PREFIX + configUrl;
-        }
+                }
 
+                logger.warn(message + ". I will try one more time with: " + configUrl);
+                try
+                {
+                    //Try one more time.
+                    url = getUrl(configUrl);
+                }
+                catch (IOException ioException)
+                {
+                    throw new ConfigurationException(message);
+                }
+            }
+        }
+        return url;
+    }
+
+    private URL getUrl(String configUrl) throws IOException
+    {
+        final URL url = new URL(configUrl);
+        url.openStream().close(); // catches well-formed but bogus URLs
         return url;
     }
 
)

> -Dcassandra.config= needs file:///
> ----------------------------------
>
>                 Key: CASSANDRA-7398
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7398
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>         Environment:  Cassandra 2.1.0-rc1-SNAPSHOT, Win 7
>            Reporter: Marco Tulio Avila Cerón
>            Priority: Minor
>              Labels: patch
>             Fix For: 2.1 rc1
>
>         Attachments: CASSANDRA-7398_prefix.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> The parameter in the VM options -Dcassandra.config= needs file:///
> Allow the user to have optional "file:///" when loading the config file from the filesystem



--
This message was sent by Atlassian JIRA
(v6.2#6252)