Skip to content

Commit 293ec4f

Browse files
committed
Merge pull request #1673 from wido/CLOUDSTACK-9071
CLOUDSTACK-9071: Properly parse stats.output.uri in StatsCollectorBoth host and path could have been NULL which causes the StatsCollector no to start properly. By checking if the Strings are not Empty or Null we make sure the StatsCollector always runs and does not prevent the Management Server from starting. * pr/1673: CLOUDSTACK-9071: Properly parse stats.output.uri in StatsCollector Signed-off-by: John Burwell <meaux@cockamamy.net>
2 parents b704cef + c1997a1 commit 293ec4f

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

server/src/com/cloud/server/StatsCollector.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import javax.inject.Inject;
3535

3636
import org.apache.cloudstack.utils.usage.UsageUtils;
37+
import org.apache.commons.lang.StringUtils;
3738
import org.apache.log4j.Logger;
3839
import org.springframework.stereotype.Component;
3940

@@ -271,12 +272,18 @@ private void init(Map<String, String> configs) {
271272
s_logger.info(scheme + " is not a valid protocol for external statistics. No statistics will be send.");
272273
}
273274

274-
externalStatsHost = uri.getHost();
275+
if (!StringUtils.isEmpty(uri.getHost())) {
276+
externalStatsHost = uri.getHost();
277+
}
278+
275279
externalStatsPort = uri.getPort();
276-
externalStatsPrefix = uri.getPath().substring(1);
280+
281+
if (!StringUtils.isEmpty(uri.getPath())) {
282+
externalStatsPrefix = uri.getPath().substring(1);
283+
}
277284

278285
/* Append a dot (.) to the prefix if it is set */
279-
if (externalStatsPrefix != null && !externalStatsPrefix.equals("")) {
286+
if (!StringUtils.isEmpty(externalStatsPrefix)) {
280287
externalStatsPrefix += ".";
281288
} else {
282289
externalStatsPrefix = "";

0 commit comments

Comments
 (0)