You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by sn...@apache.org on 2002/12/21 04:58:46 UTC

cvs commit: xml-soap/java/src/org/apache/soap/util/net HTTPUtils.java SSLUtils.java SocketUtils.java

snichol     2002/12/20 19:58:46

  Modified:    java/src/org/apache/soap/util/net HTTPUtils.java
                        SSLUtils.java SocketUtils.java
  Log:
  Improve reporting of InvocationTargetException.
  
  Revision  Changes    Path
  1.43      +14 -4     xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java
  
  Index: HTTPUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- HTTPUtils.java	20 Dec 2002 21:40:32 -0000	1.42
  +++ HTTPUtils.java	21 Dec 2002 03:58:46 -0000	1.43
  @@ -163,12 +163,17 @@
       try {
         return (Socket) buildSSLSocket.invoke(null, params);
       } catch (Exception e) {
  +      Throwable t;
  +      if (e instanceof InvocationTargetException)
  +        t = ((InvocationTargetException) e).getTargetException();
  +      else
  +        t = e;
         StringBuffer msg = new StringBuffer(512);
         msg.append("Error SSL connecting to ").append(host).append(':').append(port);
         if (httpProxyHost != null)
           msg.append(" via ").append(httpProxyHost).append(':').append(httpProxyPort);
  -      msg.append(": ").append(e.toString());
  -      throw new SOAPException(Constants.FAULT_CODE_CLIENT, msg.toString(), e);
  +      msg.append(": ").append(t.toString());
  +      throw new SOAPException(Constants.FAULT_CODE_CLIENT, msg.toString(), t);
       }
     }
   
  @@ -222,12 +227,17 @@
       try {
         s = SocketUtils.createSocket(theHost, thePort, timeout);
       } catch (Exception e) {
  +      Throwable t;
  +      if (e instanceof InvocationTargetException)
  +        t = ((InvocationTargetException) e).getTargetException();
  +      else
  +        t = e;
         StringBuffer msg = new StringBuffer(512);
         msg.append("Error connecting to ").append(host).append(':').append(port);
         if (proxyUsed.getValue())
           msg.append(" via ").append(httpProxyHost).append(':').append(httpProxyPort);
  -      msg.append(": ").append(e.toString());
  -      throw new SOAPException(Constants.FAULT_CODE_CLIENT, msg.toString(), e);
  +      msg.append(": ").append(t.toString());
  +      throw new SOAPException(Constants.FAULT_CODE_CLIENT, msg.toString(), t);
       }
   
       if (s != null && tcpNoDelay != null)
  
  
  
  1.11      +5 -7      xml-soap/java/src/org/apache/soap/util/net/SSLUtils.java
  
  Index: SSLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/net/SSLUtils.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SSLUtils.java	20 Dec 2002 21:40:32 -0000	1.10
  +++ SSLUtils.java	21 Dec 2002 03:58:46 -0000	1.11
  @@ -95,7 +95,7 @@
        */
       public static Socket buildSSLSocket(String host, int port,
                                           String tunnelHost, int tunnelPort)
  -        throws IOException, UnknownHostException {
  +        throws IOException, UnknownHostException, InvocationTargetException {
   
           return buildSSLSocket(host, port, 0,
                                 tunnelHost, tunnelPort,
  @@ -116,7 +116,7 @@
       public static Socket buildSSLSocket(String host, int port,
                                           String tunnelHost, int tunnelPort,
                                           Boolean tcpNoDelay)
  -        throws IOException, UnknownHostException {
  +        throws IOException, UnknownHostException, InvocationTargetException {
   
           return buildSSLSocket(host, port, 0,
                                 tunnelHost, tunnelPort,
  @@ -138,7 +138,7 @@
       public static Socket buildSSLSocket(String host, int port,
                                           String tunnelHost, int tunnelPort,
                                           String tunnelAuth, Boolean tcpNoDelay)
  -        throws IOException, UnknownHostException {
  +        throws IOException, UnknownHostException, InvocationTargetException {
   
           return buildSSLSocket(host, port, 0,
                                 tunnelHost, tunnelPort,
  @@ -161,7 +161,7 @@
       public static Socket buildSSLSocket(String host, int port, int timeout,
                                           String tunnelHost, int tunnelPort,
                                           String tunnelAuth, Boolean tcpNoDelay)
  -        throws IOException, UnknownHostException {
  +        throws IOException, UnknownHostException, InvocationTargetException {
   
           SSLSocket sslSocket =  null;
           SSLSocketFactory factory =
  @@ -195,8 +195,6 @@
                       sslSocket = (SSLSocket) factory.createSocket(host, port);
                   } catch (NoSuchMethodException e) {
                       sslSocket = (SSLSocket) factory.createSocket(host, port);
  -                } catch (InvocationTargetException e) {
  -                    sslSocket = (SSLSocket) factory.createSocket(host, port);
                   } catch (IllegalAccessException e) {
                       sslSocket = (SSLSocket) factory.createSocket(host, port);
                   }
  @@ -240,7 +238,7 @@
                                               String tunnelAuth,
                                               String host, int port, int timeout,
                                               Boolean tcpNoDelay)
  -            throws IOException {
  +            throws IOException, InvocationTargetException {
   
           Socket tunnel = SocketUtils.createSocket(tunnelHost, tunnelPort, timeout);
           if (tunnel != null && tcpNoDelay != null)
  
  
  
  1.2       +2 -3      xml-soap/java/src/org/apache/soap/util/net/SocketUtils.java
  
  Index: SocketUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/net/SocketUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SocketUtils.java	20 Dec 2002 21:40:32 -0000	1.1
  +++ SocketUtils.java	21 Dec 2002 03:58:46 -0000	1.2
  @@ -79,9 +79,10 @@
        *                The timeout will only be enforced for J2SE 1.4 and later.
        * @exception UnknownHostException
        * @exception IOException
  +     * @exception InvocationTargetException
        */
       public static Socket createSocket(String host, int port, int timeout)
  -            throws UnknownHostException, IOException {
  +            throws UnknownHostException, IOException, InvocationTargetException {
           Socket s;
   
           if (timeout == 0) {
  @@ -104,8 +105,6 @@
               } catch (InstantiationException e) {
                   s = new Socket(host, port);
               } catch (NoSuchMethodException e) {
  -                s = new Socket(host, port);
  -            } catch (InvocationTargetException e) {
                   s = new Socket(host, port);
               } catch (IllegalAccessException e) {
                   s = new Socket(host, port);