ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/util DOMElementWriter.java
Date Fri, 04 Apr 2003 08:36:23 GMT
bodewig     2003/04/04 00:36:22

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/junit
                        XMLJUnitResultFormatter.java
                        XMLResultAggregator.java XalanExecutor.java
               src/main/org/apache/tools/ant/util DOMElementWriter.java
  Log:
  Speed up <junitreport> by buffering output.
  
  Vastly reduce memory requirements of DOMElementWriter on JDK 1.4.1 by
  using the workaround for JDK 1.4.1's StringBuffer#toString memory leak
  (JDC BugParade Bug 4724129).
  
  PR: 18504
  Submitted by:	Andrus Adamchik <mensk at users dot sourceforge dot net>
  
  Revision  Changes    Path
  1.28      +2 -1      ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
  
  Index: XMLJUnitResultFormatter.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- XMLJUnitResultFormatter.java	28 Mar 2003 12:20:51 -0000	1.27
  +++ XMLJUnitResultFormatter.java	4 Apr 2003 08:36:22 -0000	1.28
  @@ -54,6 +54,7 @@
   
   package org.apache.tools.ant.taskdefs.optional.junit;
   
  +import java.io.BufferedWriter;
   import java.io.IOException;
   import java.io.OutputStream;
   import java.io.OutputStreamWriter;
  @@ -165,7 +166,7 @@
           if (out != null) {
               Writer wri = null;
               try {
  -                wri = new OutputStreamWriter(out, "UTF8");
  +                wri = new BufferedWriter(new OutputStreamWriter(out, "UTF8"));
                   wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
                   (new DOMElementWriter()).write(rootElement, wri, 0, "  ");
                   wri.flush();
  
  
  
  1.22      +3 -2      ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  
  Index: XMLResultAggregator.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- XMLResultAggregator.java	10 Feb 2003 14:14:16 -0000	1.21
  +++ XMLResultAggregator.java	4 Apr 2003 08:36:22 -0000	1.22
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -53,6 +53,7 @@
    */
   package org.apache.tools.ant.taskdefs.optional.junit;
   
  +import java.io.BufferedOutputStream;
   import java.io.File;
   import java.io.FileOutputStream;
   import java.io.IOException;
  @@ -228,7 +229,7 @@
           OutputStream out = null;
           PrintWriter wri = null;
           try {
  -            out = new FileOutputStream(file);
  +            out = new BufferedOutputStream(new FileOutputStream(file));
               wri = new PrintWriter(new OutputStreamWriter(out, "UTF8"));
               wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
               (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, "  ");
  
  
  
  1.9       +3 -2      ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java
  
  Index: XalanExecutor.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XalanExecutor.java	10 Feb 2003 14:14:16 -0000	1.8
  +++ XalanExecutor.java	4 Apr 2003 08:36:22 -0000	1.9
  @@ -53,6 +53,7 @@
    */
   package org.apache.tools.ant.taskdefs.optional.junit;
   
  +import java.io.BufferedOutputStream;
   import java.io.ByteArrayOutputStream;
   import java.io.File;
   import java.io.FileOutputStream;
  @@ -81,12 +82,12 @@
   
       /** get the appropriate stream based on the format (frames/noframes) */
       protected OutputStream getOutputStream() throws IOException {
  -        if (caller.FRAMES.equals(caller.format)){
  +        if (AggregateTransformer.FRAMES.equals(caller.format)){
               // dummy output for the framed report
               // it's all done by extension...
               return new ByteArrayOutputStream();
           } else {
  -            return new FileOutputStream(new File(caller.toDir, "junit-noframes.html"));
  +            return new BufferedOutputStream(new FileOutputStream(new File(caller.toDir,
"junit-noframes.html")));
           }
       }
   
  
  
  
  1.17      +5 -4      ant/src/main/org/apache/tools/ant/util/DOMElementWriter.java
  
  Index: DOMElementWriter.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/DOMElementWriter.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DOMElementWriter.java	7 Mar 2003 11:23:08 -0000	1.16
  +++ DOMElementWriter.java	4 Apr 2003 08:36:22 -0000	1.17
  @@ -205,7 +205,8 @@
        */
       public String encode(String value) {
           sb.setLength(0);
  -        for (int i = 0; i < value.length(); i++) {
  +        int len = value.length();
  +        for (int i = 0; i < len; i++) {
               char c = value.charAt(i);
               switch (c) {
               case '<':
  @@ -236,7 +237,7 @@
                   break;
               }
           }
  -        return sb.toString();
  +        return sb.substring(0);
       }
   
       /**
  @@ -261,13 +262,13 @@
               }
           }
   
  -        String result = sb.toString();
  +        String result = sb.substring(0);
           int cdEnd = result.indexOf("]]>");
           while (cdEnd != -1) {
               sb.setLength(cdEnd);
               sb.append("&#x5d;&#x5d;&gt;")
                   .append(result.substring(cdEnd+3));
  -            result = sb.toString();
  +            result = sb.substring(0);
               cdEnd = result.indexOf("]]>");
           }
           
  
  
  

Mime
View raw message