Defensive check for null returned from createConnection()

Closes gh-29706
This commit is contained in:
Juergen Hoeller 2022-12-23 15:13:41 +01:00
parent a644245e0e
commit d5ff232246
1 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -192,7 +192,13 @@ public abstract class JmsAccessor implements InitializingBean {
* @see jakarta.jms.ConnectionFactory#createConnection()
*/
protected Connection createConnection() throws JMSException {
return obtainConnectionFactory().createConnection();
ConnectionFactory cf = obtainConnectionFactory();
Connection con = cf.createConnection();
if (con == null) {
throw new jakarta.jms.IllegalStateException(
"ConnectionFactory returned null from createConnection(): " + cf);
}
return con;
}
/**