cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1145849 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/config/DatabaseDescriptor.java src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
Date Wed, 13 Jul 2011 03:18:27 GMT
Author: jbellis
Date: Wed Jul 13 03:18:27 2011
New Revision: 1145849

URL: http://svn.apache.org/viewvc?rev=1145849&view=rev
Log:
support spaces in path to log4j configuration
patch by David Allsopp; reviewed by jbellis for CASSANDRA-2383

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1145849&r1=1145848&r2=1145849&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Wed Jul 13 03:18:27 2011
@@ -1,6 +1,7 @@
 0.7.8
  * fix possibility of spurious UnavailableException for LOCAL_QUORUM
    reads with dynamic snitch + read repair disabled (CASSANDRA-2870)
+ * support spaces in path to log4j configuration (CASSANDRA-2383)
 
 
 0.7.7

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=1145849&r1=1145848&r2=1145849&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Wed Jul 13 03:18:27 2011
@@ -100,7 +100,7 @@ public class    DatabaseDescriptor
         try
         {
             url = new URL(configUrl);
-            url.openStream(); // catches well-formed but bogus URLs
+            url.openStream().close(); // catches well-formed but bogus URLs
         }
         catch (Exception e)
         {

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java?rev=1145849&r1=1145848&r2=1145849&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
Wed Jul 13 03:18:27 2011
@@ -70,12 +70,30 @@ public abstract class AbstractCassandraD
         }
         catch (MalformedURLException ex) 
         {
-            // load from the classpath.
+            // then try loading from the classpath.
             configLocation = AbstractCassandraDaemon.class.getClassLoader().getResource(config);
-            if (configLocation == null)
-                throw new RuntimeException("Couldn't figure out log4j configuration.");
         }
-        PropertyConfigurator.configureAndWatch(configLocation.getFile(), 10000);
+        
+        if (configLocation == null)
+            throw new RuntimeException("Couldn't figure out log4j configuration: "+config);
+
+        // Now convert URL to a filename
+        String configFileName = null;
+        try
+        {
+            // first try URL.getFile() which works for opaque URLs (file:foo) and paths without
spaces
+            configFileName = configLocation.getFile();
+            File configFile = new File(configFileName);
+            // then try alternative approach which works for all hierarchical URLs with or
without spaces
+            if (!configFile.exists())
+                configFileName = new File(configLocation.toURI()).getCanonicalPath();
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Couldn't convert log4j configuration location to
a valid file", e);
+        }
+
+        PropertyConfigurator.configureAndWatch(configFileName, 10000);
         org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging initialized");
     }
 



Mime
View raw message