Skip to content

Commit 07778e1

Browse files
artembilancppwfs
authored andcommitted
spring-projectsGH-10083: Apply Nullability to spring-integration-event module
Related to: spring-projects#10083 * Add `@NullMarked` to all the `event` packages * Add `@Nullable` or `@SuppressWarnings("NullAway.Init")` whenever it is requested * Fix `ApplicationEventListeningMessageProducer` logic to handle `eventTypes == null`
1 parent 395936f commit 07778e1

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes for configuration - parsers, namespace handlers.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.event.config;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides Event core classes.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.event.core;

spring-integration-event/src/main/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducer.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.HashSet;
2020
import java.util.Set;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.context.ApplicationEvent;
2325
import org.springframework.context.PayloadApplicationEvent;
2426
import org.springframework.context.event.ApplicationEventMulticaster;
@@ -49,9 +51,9 @@
4951
public class ApplicationEventListeningMessageProducer extends ExpressionMessageProducerSupport
5052
implements GenericApplicationListener {
5153

52-
private ApplicationEventMulticaster applicationEventMulticaster;
54+
private @Nullable ApplicationEventMulticaster applicationEventMulticaster;
5355

54-
private volatile Set<ResolvableType> eventTypes;
56+
private volatile @Nullable Set<ResolvableType> eventTypes;
5557

5658
private volatile long stoppedAt;
5759

@@ -74,7 +76,7 @@ public ApplicationEventListeningMessageProducer() {
7476
* @see ApplicationEventMulticaster#addApplicationListener
7577
* @see #supportsEventType
7678
*/
77-
public final void setEventTypes(Class<?>... eventTypes) {
79+
public final void setEventTypes(@Nullable Class<?>... eventTypes) {
7880
Assert.notNull(eventTypes, "'eventTypes' must not be null");
7981
Set<ResolvableType> eventSet = new HashSet<>(eventTypes.length);
8082
for (Class<?> eventType : eventTypes) {
@@ -146,11 +148,12 @@ private boolean stoppedRecently() {
146148

147149
@Override
148150
public boolean supportsEventType(ResolvableType eventType) {
149-
if (this.eventTypes == null) {
151+
Set<ResolvableType> eventTypesToCheck = this.eventTypes;
152+
if (eventTypesToCheck == null) {
150153
return true;
151154
}
152155

153-
for (ResolvableType type : this.eventTypes) {
156+
for (ResolvableType type : eventTypesToCheck) {
154157
if (type.isAssignableFrom(eventType)) {
155158
return true;
156159
}
@@ -163,7 +166,7 @@ public boolean supportsEventType(ResolvableType eventType) {
163166
}
164167

165168
ResolvableType payloadType = eventType.as(PayloadApplicationEvent.class).getGeneric();
166-
for (ResolvableType type : this.eventTypes) {
169+
for (ResolvableType type : eventTypesToCheck) {
167170
if (type.isAssignableFrom(payloadType)) {
168171
return true;
169172
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes supporting inbound endpoints.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.event.inbound;

spring-integration-event/src/main/java/org/springframework/integration/event/outbound/ApplicationEventPublishingMessageHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
public class ApplicationEventPublishingMessageHandler extends AbstractMessageHandler
4141
implements ApplicationEventPublisherAware {
4242

43+
@SuppressWarnings("NullAway.Init")
4344
private ApplicationEventPublisher applicationEventPublisher;
4445

4546
private boolean publishPayload;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes supporting outbound endpoints.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.event.outbound;

0 commit comments

Comments
 (0)