Uploaded image for project: 'JBoss Remoting'
  1. JBoss Remoting
  2. JBREM-955

CLONE [JBREM-954] - InterruptException should not be rethrown as CannotConnectionException

    Details

    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      By using getCause() on the Exception propagated, the client code could
      discover that the root Exception was an InterruptedException:

      RuntimeException.getCause() would return CannotConnectException
      CannotConnectException.getCause() would return InterruptedException

      Show
      By using getCause() on the Exception propagated, the client code could discover that the root Exception was an InterruptedException: RuntimeException.getCause() would return CannotConnectException CannotConnectException.getCause() would return InterruptedException
    • Estimated Difficulty:
      Medium

      Description

      Let's say you have a Swing GUI application that calls an EJB remotely and the
      client code is waiting to get entry to client side pool (controlled by clientMaxPoolSize).
      While waiting, the user decides to cancel the operation by interrupting the thread. In
      that case, the Remoting code does not make a difference between an InterruptedException
      and any other Exception:

      MicroSocketClientInvoker.java:

      protected SocketWrapper getConnection(Marshaller marshaller,
      UnMarshaller unmarshaller,
      int timeAllowed)
      throws Exception
      {
      long start = System.currentTimeMillis();
      long timeToWait = (timeAllowed > 0) ? timeAllowed : 30000;
      boolean timedout = !semaphore.attempt(timeToWait);

      Any Exception thrown from getConnection() is treated as a CannotConnectException

      try

      { socketWrapper = getConnection(marshaller, unmarshaller, timeLeft); }

      catch (Exception e)

      { // if (bailOut) // return null; semaphore.release(); if (trace) log.trace(this + " released semaphore: " + semaphore.permits()); throw new CannotConnectException( "Can not get connection to server. Problem establishing " + "socket connection for " + locator, e); }

      The EJB3 layer wraps this in CannotConnectException in a RuntimeException like:

      throw new RuntimeException("cluster invocation failed, last exception was: ", lastException);

      This is misleading on the Remoting side. Semantically, the fact that the thread attempting
      to connect is interrupted shouldn't be translated into a CannotConnectException.

      Please find attached a test case I've created.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ron_sigal Ronald Sigal
                  Reporter:
                  galder.zamarreno Galder ZamarreƱo
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: