Please commit this to Apache trunk as well. On Mon, Mar 26, 2012 at 1:02 PM, <[email protected]> wrote:
> Author: shankar > Date: Mon Mar 26 03:32:26 2012 > New Revision: 123874 > URL: http://wso2.org/svn/browse/wso2?view=rev&revision=123874 > > Log: > Closing the streams properly so that it will close all file handles. > > Modified: > > carbon/kernel/trunk/dependencies/axis2/1.6.1-wso2v5/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java > > Modified: > carbon/kernel/trunk/dependencies/axis2/1.6.1-wso2v5/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java > URL: > http://wso2.org/svn/browse/wso2/carbon/kernel/trunk/dependencies/axis2/1.6.1-wso2v5/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java?rev=123874&r1=123873&r2=123874&view=diff > > ============================================================================== > --- > carbon/kernel/trunk/dependencies/axis2/1.6.1-wso2v5/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java > (original) > +++ > carbon/kernel/trunk/dependencies/axis2/1.6.1-wso2v5/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java > Mon Mar 26 03:32:26 2012 > @@ -58,7 +58,9 @@ > FileOutputStream outputStream = null; > byte[] byteArray = null; > try { > - byteArray = IOUtils.getStreamAsByteArray(new > FileInputStream(file)); > + FileInputStream fin = new FileInputStream(file); > + byteArray = IOUtils.getStreamAsByteArray(fin); > + fin.close(); > inputStream = new ByteArrayInputStream(byteArray); > outputStream = new FileOutputStream(file); > > @@ -88,6 +90,18 @@ > log.debug("Pretty printed file : " + file); > } catch (Throwable t) { > log.debug("Exception occurred while trying to pretty print > file " + file, t); > + > + /* if outputStream is already created, close them, because we > are going reassign > + * different value to that. It will leak the file handle > (specially in windows, since > + * deleting is going to be an issue) > + */ > + if (outputStream != null) { > + try { > + outputStream.close(); > + } catch (IOException e) { > + log.debug(e.getMessage(), e); > + } > + } > try { > if (byteArray != null) { > outputStream = new FileOutputStream(file); > _______________________________________________ > Commits mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/commits > -- *Afkham Azeez* Director of Architecture; WSO2, Inc.; http://wso2.com Member; Apache Software Foundation; http://www.apache.org/ * <http://www.apache.org/>** email: **[email protected]* <[email protected]>* cell: +94 77 3320919 blog: **http://blog.afkham.org* <http://blog.afkham.org>* twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> * linked-in: **http://lk.linkedin.com/in/afkhamazeez* * * *Lean . Enterprise . Middleware*
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
