From 2fc78dfb69a12550548aef4f415498b7a8f1197f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 25 Mar 2024 11:27:04 +0100 Subject: [PATCH] Perform NullAway build-time checks in spring-jms See gh-32475 --- gradle/spring-module.gradle | 2 +- .../springframework/jms/connection/ConnectionFactoryUtils.java | 1 + .../springframework/jms/connection/SingleConnectionFactory.java | 1 + .../jms/listener/DefaultMessageListenerContainer.java | 1 + .../jms/listener/SimpleMessageListenerContainer.java | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gradle/spring-module.gradle b/gradle/spring-module.gradle index 2b5c46377032..fa8ef8cf672c 100644 --- a/gradle/spring-module.gradle +++ b/gradle/spring-module.gradle @@ -118,7 +118,7 @@ tasks.withType(JavaCompile).configureEach { disableAllChecks = true option("NullAway:CustomContractAnnotations", "org.springframework.lang.Contract") option("NullAway:AnnotatedPackages", "org.springframework.core,org.springframework.expression," + - "org.springframework.web") + "org.springframework.web,org.springframework.jms") option("NullAway:UnannotatedSubPackages", "org.springframework.instrument,org.springframework.context.index," + "org.springframework.asm,org.springframework.cglib,org.springframework.objenesis," + "org.springframework.javapoet,org.springframework.aot.nativex.substitution") diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java b/spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java index 03244b01ff17..b1b0ee5bd828 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java @@ -285,6 +285,7 @@ public static Session doGetTransactionalSession( * @throws JMSException in case of JMS failure */ @Nullable + @SuppressWarnings("NullAway") public static Session doGetTransactionalSession( ConnectionFactory connectionFactory, ResourceFactory resourceFactory, boolean startConnection) throws JMSException { diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java index f3ffd057bf3a..2b52e7d751d3 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java @@ -332,6 +332,7 @@ private ConnectionFactory obtainTargetConnectionFactory() { * @throws jakarta.jms.JMSException if thrown by JMS API methods * @see #initConnection() */ + @SuppressWarnings("NullAway") protected Connection getConnection() throws JMSException { this.connectionLock.lock(); try { diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java index 5e16e11c2a83..49dba0519537 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java @@ -1440,6 +1440,7 @@ private void decreaseActiveInvokerCount() { } } + @SuppressWarnings("NullAway") private void initResourcesIfNecessary() throws JMSException { if (getCacheLevel() <= CACHE_CONNECTION) { updateRecoveryMarker(); diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java index 0fe0a0efcbd4..b7c6121f6fc8 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java @@ -315,6 +315,7 @@ protected void initializeConsumers() throws JMSException { * @throws JMSException if thrown by JMS methods * @see #executeListener */ + @SuppressWarnings("NullAway") protected MessageConsumer createListenerConsumer(final Session session) throws JMSException { Destination destination = getDestination(); if (destination == null) {