Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-3547

Calling Connection.close() on interrupted thread generates InterruptedIOException and leaks Connection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 5.5.0
    • 5.6.0, 5.13.0
    • JMS client
    • None

    Description

      Similar to https://issues.apache.org/jira/browse/AMQ-3529

      call close() method on connection raise JMSException with InterruptedIOException as cause

      Sample program:

      public static void main(String[] args) throws Exception {
      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
      Connection connection = connectionFactory.createConnection();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      final Thread mainThread = Thread.currentThread();
      new Thread() {

      public void run() {
      // this thread interrupt main thread after 1s
      try

      { Thread.sleep(1000); }

      catch (InterruptedException e) {
      }
      mainThread.interrupt();
      };
      }.start();

      try

      { //wait for interrupt Thread.sleep(10000); }

      catch (InterruptedException e)

      { Thread.currentThread().interrupt(); }

      try

      { // this generate exception - bug??? connection.close(); }

      catch (JMSException e)

      { e.printStackTrace(); }

      // non-daemon thread responsible for connection still running, program
      // will not terminate
      }

      when I remove line with Session obtain, everything works OK

      Attachments

        1. AMQ3529Test.java
          3 kB
          Timothy A. Bish
        2. AMQ3529Test.java
          3 kB
          Martin Beránek

        Issue Links

          Activity

            People

              tabish Timothy A. Bish
              martin.beranek Martin Beránek
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: