Skip to content

Commit 9516d9b

Browse files
committed
Refine null-safety in the spring-jms module
Closes gh-34157
1 parent be11e73 commit 9516d9b

File tree

6 files changed

+6
-7
lines changed

6 files changed

+6
-7
lines changed

spring-core/src/main/java/org/springframework/util/CollectionUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public static boolean containsAny(Collection<?> source, Collection<?> candidates
289289
* or {@code null} if none or more than one such value found
290290
*/
291291
@SuppressWarnings("unchecked")
292-
public static <T> @Nullable T findValueOfType(Collection<?> collection, @Nullable Class<T> type) {
292+
public static <T> @Nullable T findValueOfType(@Nullable Collection<?> collection, @Nullable Class<T> type) {
293293
if (isEmpty(collection)) {
294294
return null;
295295
}

spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public boolean isSynchedLocalTransactionAllowed() {
274274
* @return the transactional Session, or {@code null} if none found
275275
* @throws JMSException in case of JMS failure
276276
*/
277-
@SuppressWarnings("NullAway")
277+
@SuppressWarnings("NullAway") // Dataflow analysis limitation
278278
public static @Nullable Session doGetTransactionalSession(
279279
ConnectionFactory connectionFactory, ResourceFactory resourceFactory, boolean startConnection)
280280
throws JMSException {

spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ public boolean containsSession(Session session) {
215215
* Return this resource holder's Session of the given type
216216
* for the given connection, or {@code null} if none.
217217
*/
218-
@SuppressWarnings("NullAway")
219218
public <S extends Session> @Nullable S getSession(Class<S> sessionType, @Nullable Connection connection) {
220219
Deque<Session> sessions =
221220
(connection != null ? this.sessionsPerConnection.get(connection) : this.sessions);

spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ private ConnectionFactory obtainTargetConnectionFactory() {
323323
* @throws jakarta.jms.JMSException if thrown by JMS API methods
324324
* @see #initConnection()
325325
*/
326-
@SuppressWarnings("NullAway")
326+
@SuppressWarnings("NullAway") // Lazy initialization
327327
protected Connection getConnection() throws JMSException {
328328
this.connectionLock.lock();
329329
try {

spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ private void decreaseActiveInvokerCount() {
14341434
}
14351435
}
14361436

1437-
@SuppressWarnings("NullAway")
1437+
@SuppressWarnings("NullAway") // Lazy initialization
14381438
private void initResourcesIfNecessary() throws JMSException {
14391439
if (getCacheLevel() <= CACHE_CONNECTION) {
14401440
updateRecoveryMarker();

spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ protected void initializeConsumers() throws JMSException {
312312
* @throws JMSException if thrown by JMS methods
313313
* @see #executeListener
314314
*/
315-
@SuppressWarnings("NullAway")
315+
@SuppressWarnings("NullAway") // Lambda
316316
protected MessageConsumer createListenerConsumer(final Session session) throws JMSException {
317317
Destination destination = getDestination();
318318
if (destination == null) {
@@ -341,7 +341,7 @@ protected MessageConsumer createListenerConsumer(final Session session) throws J
341341
* @see #executeListener
342342
* @see #setExposeListenerSession
343343
*/
344-
@SuppressWarnings("NullAway")
344+
@SuppressWarnings("NullAway") // Dataflow analysis limitation
345345
protected void processMessage(Message message, Session session) {
346346
ConnectionFactory connectionFactory = getConnectionFactory();
347347
boolean exposeResource = (connectionFactory != null && isExposeListenerSession());

0 commit comments

Comments
 (0)