Uploaded image for project: 'JBoss Remoting (3+)'
  1. JBoss Remoting (3+)
  2. REM3-300

Fix error handling in RemoteConnectionHandler.closeAction()

XMLWordPrintable

      Recently added line

      IoUtils.safeShutdownReads(remoteConnection.getChannel());

      in RemoteConnectionHandler.closeAction() swallows IOException, preventing the handler from being marked as closed, which can lead to a client hang.

          protected void closeAction() throws IOException {
              sendCloseRequest();
              remoteConnection.shutdownWrites();
              IoUtils.safeShutdownReads(remoteConnection.getChannel());
              // now these guys can't send useless messages
              closePendingChannels();
              closeAllChannels();
              remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this);
          }
      

      Additionally, AbstractHandleableCloseable.closeAsync() doesn't mark resource as closed in case when Exception other than IOException is thrown in closeAction() method. AbstractHandleableCloseable.close() does so. This is causing client hang too.

          public void closeAsync() {
              ...
              if (first) try {
                  closeAction();
              } catch (IOException e) {
                  log.tracef(e, "Close of %s failed", this);
                  final Map<Key, CloseHandler<? super T>> closeHandlers;
                  synchronized (closeLock) {
                      state = State.CLOSED;
                      closeHandlers = this.closeHandlers;
                      this.closeHandlers = null;
                      closeLock.notifyAll();
                  }
                  if (closeHandlers != null) {
                      for (final CloseHandler<? super T> handler : closeHandlers.values()) {
                          runCloseTask(new CloseHandlerTask(handler, e));
                      }
                  }
              } catch (Throwable t) {
                  log.errorf(t, "Close action for %s failed to execute (resource may be left in an indeterminate state)", this);
                  // -- here non async version marks resource as closed too --
              }
          }
      

              thofman Tomas Hofman
              thofman Tomas Hofman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: