Skip to content

Commit d5ff232

Browse files
committed
Defensive check for null returned from createConnection()
Closes gh-29706
1 parent a644245 commit d5ff232

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -192,7 +192,13 @@ protected JmsException convertJmsAccessException(JMSException ex) {
192192
* @see jakarta.jms.ConnectionFactory#createConnection()
193193
*/
194194
protected Connection createConnection() throws JMSException {
195-
return obtainConnectionFactory().createConnection();
195+
ConnectionFactory cf = obtainConnectionFactory();
196+
Connection con = cf.createConnection();
197+
if (con == null) {
198+
throw new jakarta.jms.IllegalStateException(
199+
"ConnectionFactory returned null from createConnection(): " + cf);
200+
}
201+
return con;
196202
}
197203

198204
/**

0 commit comments

Comments
 (0)