Skip to content

Commit

Permalink
Defensive check for null returned from createConnection()
Browse files Browse the repository at this point in the history
Closes gh-29706
  • Loading branch information
jhoeller committed Dec 23, 2022
1 parent 777f01d commit 0815d29
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -193,7 +193,13 @@ protected JmsException convertJmsAccessException(JMSException ex) {
* @see javax.jms.ConnectionFactory#createConnection()
*/
protected Connection createConnection() throws JMSException {
return obtainConnectionFactory().createConnection();
ConnectionFactory cf = obtainConnectionFactory();
Connection con = cf.createConnection();
if (con == null) {
throw new javax.jms.IllegalStateException(
"ConnectionFactory returned null from createConnection(): " + cf);
}
return con;
}

/**
Expand Down

0 comments on commit 0815d29

Please sign in to comment.