Skip to content

Commit

Permalink
Defensive check for null returned from createConnection()
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller authored and mdeinum committed Jun 29, 2023
1 parent 0a4610f commit e822703
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 @@ -192,7 +192,13 @@ protected JmsException convertJmsAccessException(JMSException ex) {
* @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;
}

/**
Expand Down

0 comments on commit e822703

Please sign in to comment.