mkwan       2004/03/24 07:41:13

  Modified:    java/src/org/apache/xalan/xsltc/trax TransformerImpl.java
  Log:
  Patch for bug 27417.
  
  If an output stream is created by the XSLTC transformer, close
  it after the transformation.
  
  Revision  Changes    Path
  1.81      +18 -4     
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- TransformerImpl.java      23 Feb 2004 21:33:15 -0000      1.80
  +++ TransformerImpl.java      24 Mar 2004 15:41:12 -0000      1.81
  @@ -153,6 +153,11 @@
       private TransformerFactoryImpl _tfactory = null;
   
       /**
  +     * A reference to the output stream, if we create one in our code.
  +     */
  +    private OutputStream _ostream = null;
  +
  +    /**
        * A reference to the XSLTCDTMManager which is used to build the DOM/DTM
        * for this transformer.
        */
  @@ -372,20 +377,20 @@
                if (systemId.startsWith("file:")) {
                       url = new URL(systemId);
                    _tohFactory.setOutputStream(
  -                     new FileOutputStream(url.getFile()));
  +                     _ostream = new FileOutputStream(url.getFile()));
                    return _tohFactory.getSerializationHandler();
                   }
                   else if (systemId.startsWith("http:")) {
                       url = new URL(systemId);
                       final URLConnection connection = url.openConnection();
  -                 _tohFactory.setOutputStream(connection.getOutputStream());
  +                 _tohFactory.setOutputStream(_ostream = 
connection.getOutputStream());
                    return _tohFactory.getSerializationHandler();
                   }
                   else {
                       // system id is just a filename
                       url = new File(systemId).toURL();
                    _tohFactory.setOutputStream(
  -                     new FileOutputStream(url.getFile()));
  +                     _ostream = new FileOutputStream(url.getFile()));
                    return _tohFactory.getSerializationHandler();
                   }
            }
  @@ -608,6 +613,15 @@
        } finally {
               _dtmManager = null;
           }
  +
  +     // If we create an output stream for the Result, we need to close it 
after the transformation.
  +     if (_ostream != null) {
  +         try {
  +             _ostream.close();
  +         }
  +         catch (IOException e) {}
  +         _ostream = null;
  +     }
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to