Hi Kishanthan,

We can simply fix this by putting try catch on close methods. AFAIK stream
closing shouldn't be done inside this method and it should be done by
client who invoke the public api. If we remove closing statements now that
might break existing clients. Please consider this for future releases.

Thanks,
Gayan

On Tue, Oct 27, 2015 at 9:48 AM, Kishanthan Thangarajah <[email protected]
> wrote:

> You can always fix and send a PR :)
>
> On Mon, Oct 26, 2015 at 12:19 PM, Gayan Gunawardana <[email protected]>
> wrote:
>
>> Hi Kernel Team,
>>
>> Referring to location [1] there will be possible code Improvement.
>>
>> public static void copyInputStream(InputStream in, OutputStream out)
>> throws IOException {
>>     byte[] buf = new byte[BYTE_ARRAY_SIZE];
>>     int len;
>>     while ((len = in.read(buf)) > 0) {
>>         out.write(buf, 0, len);
>>     }
>>
>>    in.close();
>>    out.close();
>> }
>>
>> If in.close() throws an IOException, out.close() would not be executed.
>> Can you please look into this ?
>>
>> [1]
>> https://github.com/wso2/carbon-kernel/blob/master/core/org.wso2.carbon.utils/src/main/java/org/wso2/carbon/utils/IOStreamUtils.java
>>
>> Thanks,
>> Gayan
>> --
>> Gayan Gunawardana
>> Software Engineer; WSO2 Inc.; http://wso2.com/
>> Email: [email protected]
>> Mobile: +94 (71) 8020933
>>
>
>
>
> --
> *Kishanthan Thangarajah*
> Associate Technical Lead,
> Platform Technologies Team,
> WSO2, Inc.
> lean.enterprise.middleware
>
> Mobile - +94773426635
> Blog - *http://kishanthan.wordpress.com <http://kishanthan.wordpress.com>*
> Twitter - *http://twitter.com/kishanthan <http://twitter.com/kishanthan>*
>



-- 
Gayan Gunawardana
Software Engineer; WSO2 Inc.; http://wso2.com/
Email: [email protected]
Mobile: +94 (71) 8020933
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to