I stumbeled upon the following code in JmsTransactionManager
The point is that inside the catch-block session will always be null. There are only two lines that can throw JMSException and these are the assignments for con and session. session is only assigned one inside the try block and this is the last line that can throw JMSException. Therefore session will always be null inside the catch-block.Code:protected void doBegin(Object transaction, TransactionDefinition definition) { //... Connection con = null; Session session = null; try { con = createConnection(); session = createSession(con); //.. } catch (JMSException ex) { if (session != null) { //session will always be null try { session.close(); } catch (Throwable ex2) { // ignore } } if (con != null) { //.. } throw new CannotCreateTransactionException("Could not create JMS transaction", ex); } }


Reply With Quote
