add file:/// on Windows to -Dcassandra.config value

patch by Marco Tulio Avila Cerón; reviewed by Lyuben Todorov for CASSANDRA-7398
This commit is contained in:
Jonathan Ellis 2014-06-18 14:05:31 -05:00
parent d6322a7ec2
commit 498ee24b52
1 changed files with 10 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.utils.FBUtilities;
import org.yaml.snakeyaml.TypeDescription;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
@ -45,6 +46,7 @@ public class YamlConfigurationLoader implements ConfigurationLoader
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
@ -53,7 +55,15 @@ public class YamlConfigurationLoader implements ConfigurationLoader
{
String configUrl = System.getProperty("cassandra.config");
if (configUrl == null)
{
configUrl = DEFAULT_CONFIGURATION;
}
else if (!FBUtilities.isUnix() && !configUrl.startsWith(FILE_PREFIX))
{
String format = "Non-unix environment detected, %s prefix not supplied at the beginning of file path but is required. Changing path to %s";
configUrl = FILE_PREFIX + configUrl;
logger.warn(String.format(format, FILE_PREFIX, configUrl));
}
URL url;
try