3 Replies Latest reply on Dec 22, 2009 8:25 AM by jmesnil

    Session.close should use afterCompletion?

    clebert.suconic

      I thought about this last week, while on the beach enjoying my vacations :-)...

       

       

      And I just came back, looked at the code and confirmed what I thought....

       

       

      Session.close is immediately closing the session without waiting any pending requests.

       

      Say, if another thread close the session, any waiting response will never return.. and that's currently (occasionally) happening in some of the MultiThread tests.


       

      To fix that, I would need to change Serversession::handleClose to:

       

       

         public void handleClose(final Packet packet)
         {
            storageManager.afterCompleteOperations(new IOAsyncTask()
            {
               public void onError(int errorCode, String errorMessage)
               {
               }
              
               public void done()
               {
                  doHandleClose(packet);
               }
            });
         }

       

         private void doHandleClose(final Packet packet)
         {
            Packet response = null;

       

            try
            {
               close();

       

               response = new NullResponseMessage();
            }
            catch (Exception e)
            {
               ServerSessionImpl.log.error("Failed to close", e);

       

               if (e instanceof HornetQException)
               {
                  response = new HornetQExceptionMessage((HornetQException)e);
               }
               else
               {
                  response = new HornetQExceptionMessage(new HornetQException(HornetQException.INTERNAL_ERROR));
               }
            }

       

            sendResponse(packet, response, true, true);

       

         }

       

       

      I know the Session is supposed to be single threaded, but I believe some of the MultiThreadReattachTests are failing because of this.

       

       

      the fix is simple, but I don't know if I should do it now since I don't have much time to test this. Any ideas?