No need to close Session/Producer after closing Connection with JMS 2.0

Hi,

according to the docs:

There is no need to close the sessions, producers, and consumers of a closed connection.

This code should therefore be fine:

try (javax.jms.Connection conn = connFactory.createConnection()){
            Session sess = conn.createSession();
            MessageProducer producer = sess.createProducer(taskQueue);
            ObjectMessage msg = sess.createObjectMessage();
            msg.setObject(t);
            producer.send(msg);
        }

But Sonar still wants me to close Session and MessageProducer.

Is there anything I can do about this besides ignoring it, any configuration missing for SonarLint? JMS 2.0 is out for quite some time and I think this rule (S2095) should reflect that.

Hello,

Thanks for reporting this issue, indeed, this is a wrong behavior of the rule and should be improved. Ticket created: SONARJAVA-3451.

Best,
Quentin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.