Skip to content

Commit 0815d29

Browse files
committed
Defensive check for null returned from createConnection()
Closes gh-29706
1 parent 777f01d commit 0815d29

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.
@@ -193,7 +193,13 @@ protected JmsException convertJmsAccessException(JMSException ex) {
193193
* @see javax.jms.ConnectionFactory#createConnection()
194194
*/
195195
protected Connection createConnection() throws JMSException {
196-
return obtainConnectionFactory().createConnection();
196+
ConnectionFactory cf = obtainConnectionFactory();
197+
Connection con = cf.createConnection();
198+
if (con == null) {
199+
throw new javax.jms.IllegalStateException(
200+
"ConnectionFactory returned null from createConnection(): " + cf);
201+
}
202+
return con;
197203
}
198204

199205
/**

0 commit comments

Comments
 (0)