Skip to content

Commit aa29bb1

Browse files
committed
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`
1 parent c4ec73f commit aa29bb1

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

spring-integration-core/src/main/java/org/springframework/integration/graph/MessageChannelNode.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
import java.util.function.Supplier;
2020

21+
import org.springframework.lang.Nullable;
2122
import org.springframework.messaging.MessageChannel;
2223

2324
/**
2425
* Represents a message channel.
2526
*
2627
* @author Gary Russell
28+
* @author Artem Bilan
2729
*
2830
* @since 4.3
2931
*
@@ -40,8 +42,9 @@ public MessageChannelNode(int nodeId, String name, MessageChannel channel) {
4042
: new IntegrationNode.Stats());
4143
}
4244

45+
@Nullable
4346
public SendTimers getSendTimers() {
44-
return this.sendTimers.get();
47+
return this.sendTimers != null ? this.sendTimers.get() : null;
4548
}
4649

4750
@Override

spring-integration-core/src/main/java/org/springframework/integration/graph/MessageHandlerNode.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
import java.util.function.Supplier;
2020

21+
import org.springframework.lang.Nullable;
2122
import org.springframework.messaging.MessageHandler;
2223

2324
/**
2425
* Represents a message handler.
2526
*
2627
* @author Gary Russell
28+
* @author Artem Bilan
2729
*
2830
* @since 4.3
2931
*
@@ -47,8 +49,9 @@ public String getInput() {
4749
return this.input;
4850
}
4951

52+
@Nullable
5053
public SendTimers getSendTimers() {
51-
return this.sendTimers.get();
54+
return this.sendTimers != null ? this.sendTimers.get() : null;
5255
}
5356

5457
@Override

spring-integration-core/src/main/java/org/springframework/integration/graph/MessageSourceNode.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
import java.util.function.Supplier;
2020

2121
import org.springframework.integration.core.MessageSource;
22+
import org.springframework.lang.Nullable;
2223

2324
/**
2425
* Represents a message source.
2526
*
2627
* @author Gary Russell
28+
* @author Artem Bilan
2729
*
2830
* @since 4.3
2931
*
@@ -41,8 +43,9 @@ public MessageSourceNode(int nodeId, String name, MessageSource<?> messageSource
4143
: new IntegrationNode.Stats());
4244
}
4345

46+
@Nullable
4447
public ReceiveCounters getReceiveCounters() {
45-
return this.receiveCounters.get();
48+
return this.receiveCounters != null ? this.receiveCounters.get() : null;
4649
}
4750

4851
@Override

spring-integration-core/src/main/java/org/springframework/integration/graph/PollableChannelNode.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818

1919
import java.util.function.Supplier;
2020

21+
import org.springframework.lang.Nullable;
2122
import org.springframework.messaging.MessageChannel;
2223

2324
/**
2425
* Represents a pollable channel.
2526
*
2627
* @author Gary Russell
28+
* @author Artem Bilan
29+
*
2730
* @since 5.2
2831
*
2932
*/
@@ -35,8 +38,9 @@ public PollableChannelNode(int nodeId, String name, MessageChannel channel) {
3538
super(nodeId, name, channel);
3639
}
3740

41+
@Nullable
3842
public ReceiveCounters getReceiveCounters() {
39-
return this.receiveCounters.get();
43+
return this.receiveCounters != null ? this.receiveCounters.get() : null;
4044
}
4145

4246
@Override

0 commit comments

Comments
 (0)