cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject cassandra git commit: NullPointerException if metrics reporter config file doesn't exist
Date Fri, 22 Apr 2016 12:22:23 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk a18402ca0 -> 7afc1571b


NullPointerException if metrics reporter config file doesn't exist

patch by Christopher Batey; reviewed by Robert Stupp for CASSANDRA-11544


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7afc1571
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7afc1571
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7afc1571

Branch: refs/heads/trunk
Commit: 7afc1571bb465ba45572f849e6f285182b6c1e7d
Parents: a18402c
Author: Christopher Batey <christopher.batey@gmail.com>
Authored: Fri Apr 22 14:21:23 2016 +0200
Committer: Robert Stupp <snazy@snazy.de>
Committed: Fri Apr 22 14:21:23 2016 +0200

----------------------------------------------------------------------
 .../org/apache/cassandra/service/CassandraDaemon.java     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7afc1571/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index 160235a..0c233a7 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.lang.management.MemoryPoolMXBean;
 import java.net.InetAddress;
+import java.net.URL;
 import java.net.UnknownHostException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.server.RMIServerSocketFactory;
@@ -327,8 +328,13 @@ public class CassandraDaemon
             logger.info("Trying to load metrics-reporter-config from file: {}", metricsReporterConfigFile);
             try
             {
-                String reportFileLocation = CassandraDaemon.class.getClassLoader().getResource(metricsReporterConfigFile).getFile();
-                ReporterConfig.loadFromFile(reportFileLocation).enableAll(CassandraMetricsRegistry.Metrics);
+                URL resource = CassandraDaemon.class.getClassLoader().getResource(metricsReporterConfigFile);
+                if (resource == null) {
+                    logger.warn("Failed to load metrics-reporter-config, file does not exist:
{}", metricsReporterConfigFile);
+                } else {
+                    String reportFileLocation = resource.getFile();
+                    ReporterConfig.loadFromFile(reportFileLocation).enableAll(CassandraMetricsRegistry.Metrics);
+                }
             }
             catch (Exception e)
             {


Mime
View raw message