Guard Micrometer stats for NPE: no Micrometer

If there is no Micrometer in classpath, the `timers` and `counters`
are not populated into Graph

* Check for `null` before calling `Supplier`
This commit is contained in:
Artem Bilan
2019-09-20 09:45:04 -04:00
parent c4ec73f9a0
commit aa29bb15e3
4 changed files with 17 additions and 4 deletions

View File

@@ -18,12 +18,14 @@ package org.springframework.integration.graph;
import java.util.function.Supplier;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageChannel;
/**
* Represents a message channel.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.3
*
@@ -40,8 +42,9 @@ public class MessageChannelNode extends IntegrationNode implements SendTimersAwa
: new IntegrationNode.Stats());
}
@Nullable
public SendTimers getSendTimers() {
return this.sendTimers.get();
return this.sendTimers != null ? this.sendTimers.get() : null;
}
@Override

View File

@@ -18,12 +18,14 @@ package org.springframework.integration.graph;
import java.util.function.Supplier;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageHandler;
/**
* Represents a message handler.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.3
*
@@ -47,8 +49,9 @@ public class MessageHandlerNode extends EndpointNode implements SendTimersAware
return this.input;
}
@Nullable
public SendTimers getSendTimers() {
return this.sendTimers.get();
return this.sendTimers != null ? this.sendTimers.get() : null;
}
@Override

View File

@@ -19,11 +19,13 @@ package org.springframework.integration.graph;
import java.util.function.Supplier;
import org.springframework.integration.core.MessageSource;
import org.springframework.lang.Nullable;
/**
* Represents a message source.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.3
*
@@ -41,8 +43,9 @@ public class MessageSourceNode extends ErrorCapableEndpointNode implements Recei
: new IntegrationNode.Stats());
}
@Nullable
public ReceiveCounters getReceiveCounters() {
return this.receiveCounters.get();
return this.receiveCounters != null ? this.receiveCounters.get() : null;
}
@Override

View File

@@ -18,12 +18,15 @@ package org.springframework.integration.graph;
import java.util.function.Supplier;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageChannel;
/**
* Represents a pollable channel.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.2
*
*/
@@ -35,8 +38,9 @@ public class PollableChannelNode extends MessageChannelNode implements ReceiveCo
super(nodeId, name, channel);
}
@Nullable
public ReceiveCounters getReceiveCounters() {
return this.receiveCounters.get();
return this.receiveCounters != null ? this.receiveCounters.get() : null;
}
@Override