You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2001/06/06 17:01:34 UTC

cvs commit: xml-axis/java/samples/transport FileReader.java

rubys       01/06/06 08:01:33

  Modified:    java/samples/transport FileReader.java
  Log:
  Reorder logic so the same file isn't processed over and over again ad
  infinitum when there is an error.  Noticed when running the functional
  tests while http://www.xmltoday.com/ was inaccessible, causing an
  AxisFault.
  
  Revision  Changes    Path
  1.3       +13 -9     xml-axis/java/samples/transport/FileReader.java
  
  Index: FileReader.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/transport/FileReader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileReader.java	2001/06/02 04:01:15	1.2
  +++ FileReader.java	2001/06/06 15:01:28	1.3
  @@ -89,7 +89,9 @@
             if (pleaseStop) continue;
   
           Thread.sleep( 100 );   // let the other side finish writing
  -        FileInputStream fis = new FileInputStream( "xml" + nextNum + ".req" );
  +        FileInputStream fis = new FileInputStream( file );
  +        FileOutputStream fos = new FileOutputStream( "xml" + nextNum + ".res" );
  +        nextNum++ ;
   
           Message msg = new Message( fis, "InputStream" );
           MessageContext  msgContext = new MessageContext();
  @@ -101,18 +103,20 @@
           String action = new String( buf );
           msgContext.setTargetService( action.trim() );
           // end of hack
  -
  -        server.invoke( msgContext );
  -        msg = msgContext.getResponseMessage();
  -        fis.close();
   
  -        (new File("xml" + nextNum + ".req" )).delete();
  +        try {
  +            server.invoke( msgContext );
  +            msg = msgContext.getResponseMessage();
  +            buf = (byte[]) msg.getAs( "Bytes" );
  +        } catch (Exception e) {
  +            buf = e.toString().getBytes();
  +        }
   
  -        FileOutputStream fos = new FileOutputStream( "xml" + nextNum + ".res" );
  -        buf = (byte[]) msg.getAs( "Bytes" );
           fos.write( buf );
           fos.close();
  -        nextNum++ ;
  +
  +        fis.close();
  +        file.delete();
         }
         catch( Exception e ) {
           if ( !(e instanceof FileNotFoundException) )