logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject cvs commit: logging-log4j/src/java/org/apache/log4j/xml XMLDecoder.java
Date Sun, 08 Aug 2004 23:28:12 GMT
psmith      2004/08/08 16:28:11

  Modified:    src/java/org/apache/log4j/xml XMLDecoder.java
  Log:
  Commiting patch contributed by Stephen Pain that fixes the patch that I committed last week
to fix a problem Stephen found originally.....
  
  Maybe I should have just let Stephen do it in the first place... :)
  
  It sucks that this won't support unlimited XML size for an event, but it is better than
taking forever to load a file, or causing an error.
  
  My only change is that I append a "\n" after every line so the stack traces appear nicely
inside Chainsaw.
  
  Revision  Changes    Path
  1.22      +8 -22     logging-log4j/src/java/org/apache/log4j/xml/XMLDecoder.java
  
  Index: XMLDecoder.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/xml/XMLDecoder.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- XMLDecoder.java	4 Aug 2004 03:48:12 -0000	1.21
  +++ XMLDecoder.java	8 Aug 2004 23:28:11 -0000	1.22
  @@ -25,7 +25,6 @@
   import java.util.HashMap;
   import java.util.Hashtable;
   import java.util.Iterator;
  -import java.util.List;
   import java.util.Map;
   import java.util.Vector;
   
  @@ -156,23 +155,16 @@
       Vector v = new Vector();
   
       String line = null;
  +	Vector events = null;
       try {
  -        /**
  -         * Keep reading in the lines until we find the end of record line
  -         * 
  -         * NOTE: this might chew a bit more memory than the previous implementation which
  -         * read in line blocks of 100, but allows a HUGE event spread over 100+ lines to
be decode correctly.
  -         */
           while ((line = reader.readLine()) != null) {
  -            StringBuffer buffer = new StringBuffer(512);
  -            while(line!=null && line.indexOf(RECORD_END)==-1) {
  -                buffer.append(line).append("\n");
  -                line = reader.readLine();
  +            StringBuffer buffer = new StringBuffer(line);
  +            for (int i = 0;i<1000;i++) {
  +                buffer.append(reader.readLine()).append("\n");
               }
  -            if(line!=null) {
  -             buffer.append(line);   
  -            }
  -            v.addAll(decodeEvents(buffer.toString()));
  +			events = decodeEvents(buffer.toString());
  +            if (events != null)
  +            	v.addAll(events);
           }
       } finally {
         partialEvent = null;
  @@ -188,16 +180,10 @@
     }
   
     public Vector decodeEvents(String document) {
  -    /**
  -     * NOTE: due to the logic above, which should read in the string containing the WHOLE
event text,
  -     * there should be no need to track partial events, but I have not changed the code
just in case....
  -     * 
  -     * Paul Smith 4th August 2004
  -     */
       if (document != null) {
         document = document.trim();
         if (document.equals("")) {
  -        return new Vector();
  +        return null;
         } else {
         	String newDoc=null;
         	String newPartialEvent=null;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message