Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Agent: avoid NPE if http server is not yet started
Browse files Browse the repository at this point in the history
  • Loading branch information
bleskes committed Feb 11, 2015
1 parent 1050086 commit 9bd8a7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions agent/src/main/java/org/elasticsearch/marvel/agent/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ public static String nodeDescription(DiscoveryNode node) {

public static String[] extractHostsFromHttpServer(HttpServer httpServer, ESLogger logger) {
logger.debug("deriving host setting from httpServer");
BoundTransportAddress boundAddress = httpServer.info().address();
if (httpServer.lifecycleState() != Lifecycle.State.STARTED || boundAddress == null || boundAddress.boundAddress() == null) {
BoundTransportAddress boundAddress = null;
if (httpServer.lifecycleState() == Lifecycle.State.STARTED) {
boundAddress = httpServer.info().address();
}

if (boundAddress == null || boundAddress.boundAddress() == null) {
logger.debug("local http server is not yet started. can't connect");
return null;
}

if (boundAddress.boundAddress().uniqueAddressTypeId() != 1) {
logger.error("local node is not bound via the http transport. can't connect");
return null;
Expand Down

0 comments on commit 9bd8a7f

Please sign in to comment.