Skip to content

Commit 1a09b5a

Browse files
committed
GH-10083: Nullability for graph in core module
* Add Nullability to core module's graph package. * `buildGraph` and `getGraph` methods in the `IntegrationGraphServer` because Nullify could not see the creation of the graph * `IntegrationGraphServer.receiptListRoutingHandler` required a change where the messageChannel could not be null in the `map` portion of expression. So it was extracted into a var and the var was checked for null.
1 parent ce6e398 commit 1a09b5a

20 files changed

+111
-68
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.messaging.MessageHandler;
2325

2426
/**
@@ -33,7 +35,7 @@ public class CompositeMessageHandlerNode extends MessageHandlerNode {
3335

3436
private final List<InnerHandler> handlers = new ArrayList<>();
3537

36-
public CompositeMessageHandlerNode(int nodeId, String name, MessageHandler handler, String input, String output,
38+
public CompositeMessageHandlerNode(int nodeId, String name, MessageHandler handler, @Nullable String input, @Nullable String output,
3739
List<InnerHandler> handlers) {
3840

3941
super(nodeId, name, handler, input, output);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.graph;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.messaging.MessageHandler;
2022

2123
/**
@@ -28,16 +30,16 @@
2830
*/
2931
public class DiscardingMessageHandlerNode extends MessageHandlerNode {
3032

31-
private final String discards;
33+
private final @Nullable String discards;
3234

33-
public DiscardingMessageHandlerNode(int nodeId, String name, MessageHandler handler, String input, String output,
34-
String discards) {
35+
public DiscardingMessageHandlerNode(int nodeId, String name, MessageHandler handler, @Nullable String input,
36+
@Nullable String output, @Nullable String discards) {
3537

3638
super(nodeId, name, handler, input, output);
3739
this.discards = discards;
3840
}
3941

40-
public String getDiscards() {
42+
public @Nullable String getDiscards() {
4143
return this.discards;
4244
}
4345

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.graph;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
/**
2022
* Base class for all endpoints.
2123
*
@@ -26,14 +28,14 @@
2628
*/
2729
public abstract class EndpointNode extends IntegrationNode {
2830

29-
private final String output;
31+
private final @Nullable String output;
3032

31-
protected EndpointNode(int nodeId, String name, Object nodeObject, String output) {
33+
protected EndpointNode(int nodeId, String name, Object nodeObject, @Nullable String output) {
3234
super(nodeId, name, nodeObject);
3335
this.output = output;
3436
}
3537

36-
public String getOutput() {
38+
public @Nullable String getOutput() {
3739
return this.output;
3840
}
3941

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.util.List;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.integration.handler.CompositeMessageHandler;
2224

2325
/**
@@ -31,17 +33,17 @@
3133
*/
3234
public class ErrorCapableCompositeMessageHandlerNode extends CompositeMessageHandlerNode implements ErrorCapableNode {
3335

34-
private final String errors;
36+
private final @Nullable String errors;
3537

36-
public ErrorCapableCompositeMessageHandlerNode(int nodeId, String name, CompositeMessageHandler handler, String input,
37-
String output, String errors, List<InnerHandler> handlers) {
38+
public ErrorCapableCompositeMessageHandlerNode(int nodeId, String name, CompositeMessageHandler handler,
39+
@Nullable String input, @Nullable String output, @Nullable String errors, List<InnerHandler> handlers) {
3840

3941
super(nodeId, name, handler, input, output, handlers);
4042
this.errors = errors;
4143
}
4244

4345
@Override
44-
public String getErrors() {
46+
public @Nullable String getErrors() {
4547
return this.errors;
4648
}
4749

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.graph;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.messaging.MessageHandler;
2022

2123
/**
@@ -29,17 +31,17 @@
2931
*/
3032
public class ErrorCapableDiscardingMessageHandlerNode extends DiscardingMessageHandlerNode implements ErrorCapableNode {
3133

32-
private final String errors;
34+
private final @Nullable String errors;
3335

34-
public ErrorCapableDiscardingMessageHandlerNode(int nodeId, String name, MessageHandler handler, String input,
35-
String output, String discards, String errors) {
36+
public ErrorCapableDiscardingMessageHandlerNode(int nodeId, String name, MessageHandler handler, @Nullable String input,
37+
@Nullable String output, @Nullable String discards, @Nullable String errors) {
3638

3739
super(nodeId, name, handler, input, output, discards);
3840
this.errors = errors;
3941
}
4042

4143
@Override
42-
public String getErrors() {
44+
public @Nullable String getErrors() {
4345
return this.errors;
4446
}
4547

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.graph;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
/**
2022
* Represents nodes that can natively handle errors.
2123
*
@@ -26,15 +28,15 @@
2628
*/
2729
public class ErrorCapableEndpointNode extends EndpointNode implements ErrorCapableNode {
2830

29-
private final String errors;
31+
private final @Nullable String errors;
3032

31-
protected ErrorCapableEndpointNode(int nodeId, String name, Object nodeObject, String output, String errors) {
33+
protected ErrorCapableEndpointNode(int nodeId, String name, Object nodeObject, @Nullable String output, @Nullable String errors) {
3234
super(nodeId, name, nodeObject, output);
3335
this.errors = errors;
3436
}
3537

3638
@Override
37-
public String getErrors() {
39+
public @Nullable String getErrors() {
3840
return this.errors;
3941
}
4042

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.graph;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.messaging.MessageHandler;
2022

2123
/**
@@ -27,17 +29,17 @@
2729
*/
2830
public class ErrorCapableMessageHandlerNode extends MessageHandlerNode implements ErrorCapableNode {
2931

30-
private final String errors;
32+
private final @Nullable String errors;
3133

32-
public ErrorCapableMessageHandlerNode(int nodeId, String name, MessageHandler handler, String input,
33-
String output, String errors) {
34+
public ErrorCapableMessageHandlerNode(int nodeId, String name, MessageHandler handler, @Nullable String input,
35+
@Nullable String output, @Nullable String errors) {
3436

3537
super(nodeId, name, handler, input, output);
3638
this.errors = errors;
3739
}
3840

3941
@Override
40-
public String getErrors() {
42+
public @Nullable String getErrors() {
4143
return this.errors;
4244
}
4345

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.graph;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
/**
2022
* Nodes implementing this interface are capable of emitting errors.
2123
*
@@ -26,6 +28,7 @@
2628
*/
2729
public interface ErrorCapableNode {
2830

31+
@Nullable
2932
String getErrors();
3033

3134
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.util.Collection;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.messaging.MessageHandler;
2224

2325
/**
@@ -31,17 +33,17 @@
3133
*/
3234
public class ErrorCapableRoutingNode extends RoutingMessageHandlerNode implements ErrorCapableNode {
3335

34-
private final String errors;
36+
private final @Nullable String errors;
3537

36-
public ErrorCapableRoutingNode(int nodeId, String name, MessageHandler handler, String input, String output,
37-
String errors, Collection<String> routes) {
38+
public ErrorCapableRoutingNode(int nodeId, String name, MessageHandler handler, @Nullable String input, @Nullable String output,
39+
@Nullable String errors, Collection<String> routes) {
3840

3941
super(nodeId, name, handler, input, output, routes);
4042
this.errors = errors;
4143
}
4244

4345
@Override
44-
public String getErrors() {
46+
public @Nullable String getErrors() {
4547
return this.errors;
4648
}
4749

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.graph;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.aot.hint.BindingReflectionHintsRegistrar;
2022
import org.springframework.aot.hint.RuntimeHints;
2123
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@@ -31,7 +33,7 @@
3133
class IntegrationGraphRuntimeHints implements RuntimeHintsRegistrar {
3234

3335
@Override
34-
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
36+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
3537
new BindingReflectionHintsRegistrar()
3638
.registerReflectionHints(hints.reflection(),
3739
Graph.class,

0 commit comments

Comments
 (0)