[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/http ...

Ron Sigal ron_sigal at yahoo.com
Fri Aug 17 21:19:56 EDT 2007


  User: rsigal  
  Date: 07/08/17 21:19:56

  Modified:    src/main/org/jboss/remoting/transport/http  Tag:
                        remoting_2_2_2_experimental HTTPClientInvoker.java
  Log:
  JBREM-754: (1) For jdk 1.4 per invocation timeouts, wrap timeout exception in CannotConnectException; (2) explictly set timeout to 0 if no timeout is specified.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.31.2.3.4.2.2.1 +7 -9      JBossRemoting/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HTTPClientInvoker.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java,v
  retrieving revision 1.31.2.3.4.2
  retrieving revision 1.31.2.3.4.2.2.1
  diff -u -b -r1.31.2.3.4.2 -r1.31.2.3.4.2.2.1
  --- HTTPClientInvoker.java	15 Aug 2007 06:12:01 -0000	1.31.2.3.4.2
  +++ HTTPClientInvoker.java	18 Aug 2007 01:19:56 -0000	1.31.2.3.4.2.2.1
  @@ -130,7 +130,7 @@
         
         int simulatedTimeout = getSimulatedTimeout(configuration, metadata, conn);
         
  -      if (simulatedTimeout < 0)
  +      if (simulatedTimeout <= 0)
         {
            return useHttpURLConnection(conn, invocation, metadata, marshaller, unmarshaller);
         }
  @@ -172,7 +172,8 @@
            if (result == null)
            {
               if (log.isDebugEnabled()) log.debug("invocation timed out");
  -            throw new SocketTimeoutException("timed out");
  +            Exception cause = new SocketTimeoutException("timed out");
  +            throw new CannotConnectException("Can not connect http client invoker.", cause);
            }
            else if (result instanceof IOException)
            {
  @@ -519,7 +520,6 @@
   
      private int getSimulatedTimeout(Map configuration, Map metadata, HttpURLConnection conn)
      {
  -      int simulatedTimeout = -1;
         int timeout = -1;
         String connectionTimeout = (String) configuration.get("timeout");
         String invocationTimeout = (String) metadata.get("timeout");
  @@ -549,7 +549,7 @@
         }
         
         if (timeout < 0)
  -         return -1;
  +         timeout = 0;
   
         /**
          * Since URLConnection in jdk 1.4 does NOT have a setConnectTimeout() method and
  @@ -562,26 +562,24 @@
            setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)});
            setTimeoutMethod = conn.getClass().getMethod("setReadTimeout", new Class[]{int.class});
            setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)});
  +         return -1;
         }
         catch (NoSuchMethodException e)
         {
  -         simulatedTimeout = timeout;
            log.debug("Using older JDK (prior to 1.5): will simulate timeout");
         }
         catch (IllegalAccessException e)
         {
  -         simulatedTimeout = timeout;
            log.error("Error setting http client connection timeout.");
            log.debug(e);
         }
         catch (InvocationTargetException e)
         {
  -         simulatedTimeout = timeout;
            log.error("Error setting http client connection timeout.");
            log.debug(e);
         }
         
  -      return simulatedTimeout;
  +      return timeout;
      }
   
      protected String validateURL(String url)
  
  
  



More information about the jboss-cvs-commits mailing list