You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rpc-dev@xml.apache.org by ha...@apache.org on 2002/02/01 15:23:45 UTC

cvs commit: xml-rpc/src/java/org/apache/xmlrpc XmlRpcServer.java

hannes      02/02/01 06:23:45

  Modified:    src/java/org/apache/xmlrpc XmlRpcServer.java
  Log:
  Reset response StringBuffer before  writing error message.
  
  Actually, to put  the responsability to pass an empty string buffer on the caller of the
  XmlWriter constructor is pretty stupid (and has caused a lot of bugs), because the
  string buffer is internal to the XmlWriter anyway. The original idea was to reduce
  object instantiation, but I'm not sure it was worth the trouble...
  
  From Chad Ward (cward@arcsight.com):
  
  If an exception occurs during the writing of the response, it is possible that there
  is some could be some residual data in the buffer.  In the exception
  block a new XmlWriter is created, but the buffer is not cleared.
  Because the exception is not printed on the server and the stream is
  not parsable by the console, the exception will be lost.
  
  Revision  Changes    Path
  1.9       +8 -0      xml-rpc/src/java/org/apache/xmlrpc/XmlRpcServer.java
  
  Index: XmlRpcServer.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/XmlRpcServer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XmlRpcServer.java	26 Jan 2002 07:50:42 -0000	1.8
  +++ XmlRpcServer.java	1 Feb 2002 14:23:45 -0000	1.9
  @@ -243,6 +243,14 @@
               {
                   if (debug)
                       x.printStackTrace ();
  +
  +                // Ensure that if there is anything in the buffer, it
  +                // is cleared before continuing with the writing of exceptions.
  +                // It is possible that something is in the buffer
  +                // if there were an exception during the writeResponse()
  +                // call above.
  +                strbuf.setLength(0);
  +
                   XmlWriter writer = new XmlWriter (strbuf);
                   String message = x.toString ();
                   // check if XmlRpcException was thrown so we can get an error code