vgritsenko    02/01/24 19:46:35

  Modified:    src/java/org/apache/cocoon/environment/commandline
                        AbstractCommandLineEnvironment.java
  Log:
  Always recycle sources.
  
  Revision  Changes    Path
  1.3       +13 -3     
xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
  
  Index: AbstractCommandLineEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractCommandLineEnvironment.java       22 Jan 2002 00:17:12 -0000      1.2
  +++ AbstractCommandLineEnvironment.java       25 Jan 2002 03:46:35 -0000      1.3
  @@ -27,7 +27,7 @@
    * This environment is used to save the requested file to disk.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/01/22 00:17:12 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/01/25 03:46:35 $
    */
   
   public abstract class AbstractCommandLineEnvironment
  @@ -57,15 +57,18 @@
           if (sessionmode) {
               CommandLineSession.getSession(true);
           }
  +
           // fix all urls created with request.getScheme()+... etc.
           if (newURL.startsWith("cli:/")) {
               int pos = newURL.indexOf('/', 6);
               newURL = newURL.substring(pos+1);
           }
  +
           // fix all relative urls to use to cocoon: protocol
           if (newURL.indexOf(":") == -1) {
               newURL = "cocoon:/" + newURL;
           }
  +
           // FIXME: this is a hack for the links view
           if (newURL.startsWith("cocoon:")
               && this.getView() != null
  @@ -78,17 +81,22 @@
               org.apache.cocoon.serialization.LinkSerializer ls =
                   new org.apache.cocoon.serialization.LinkSerializer();
               ls.setOutputStream(this.stream);
  +
  +            Source redirectSource = null;
               try {
  -                final Source redirectSource = this.resolve(newURL);
  +                redirectSource = this.resolve(newURL);
                   redirectSource.toSAX(ls);
               } catch (SAXException se) {
                   throw new IOException("SAXException: " + se);
               } catch (ProcessingException pe) {
                   throw new IOException("ProcessingException: " + pe);
  +            } finally {
  +                if (redirectSource != null) redirectSource.recycle();
               }
           } else {
  +            Source redirectSource = null;
               try {
  -                final Source redirectSource = this.resolve(newURL);
  +                redirectSource = this.resolve(newURL);
                   InputStream is = redirectSource.getInputStream();
                   byte[] buffer = new byte[8192];
                   int length = -1;
  @@ -100,6 +108,8 @@
                   throw new IOException("SAXException: " + se);
               } catch (ProcessingException pe) {
                   throw new IOException("ProcessingException: " + pe);
  +            } finally {
  +                if (redirectSource != null) redirectSource.recycle();
               }
           }
       }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to