FYI,

I've encountered the "Method may fail to clean up stream or resource" error
in the following method.

public void archiveFile(String from, String to) throws IOException {
        FileInputStream in = new FileInputStream(from);
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(to));
        byte[] buffer = new byte[40960];
        int bytesRead;
        while ((bytesRead = in.read(buffer)) != -1) {
            out.write(buffer, 0, bytesRead);
        }
    }

I fixed in the following manner.

public void archiveFile(String from, String to) throws IOException {
        ZipOutputStream out = null;
        FileInputStream in = new FileInputStream(from);
        try {
            out = new ZipOutputStream(new FileOutputStream(to));
            byte[] buffer = new byte[40960];
            int bytesRead;
            while ((bytesRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, bytesRead);
            }
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                log.warn("Unable to close the InputStream " +
e.getMessage(), e);
            }

            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
                log.warn("Unable to close the OutputStream " +
e.getMessage(), e);
            }
        }
    }

IMV, we need to close streams in the above manner, otherwise output stream
won't get closed, if an error occurs while closing the input stream.

Thanks
Sameera

On Fri, Sep 24, 2010 at 12:26 PM, Sameera Jayasoma <same...@wso2.com> wrote:

> Hi Azeez,
>
> Will start working on the Carbon project first.
>
> Thanks
> Sameera
>
> On Fri, Sep 24, 2010 at 12:20 PM, Thilina Mahesh Buddhika <
> thili...@wso2.com> wrote:
>
>> Hi Azeez,
>>
>> I have started working on Security component. Then I can move on to XKMS
>> component.
>>
>> Thanks,
>> Thilina
>>
>> On Fri, Sep 24, 2010 at 12:12 PM, Afkham Azeez <az...@wso2.com> wrote:
>>
>>> I'm expecting a response, at least from the folks whose names have been
>>> listed below. We also need more volunteers.
>>>
>>> Azeez
>>>
>>>
>>> On Fri, Sep 24, 2010 at 9:57 AM, Afkham Azeez <az...@wso2.com> wrote:
>>>
>>>> Folks,
>>>> I'd like to see more enthusiasm in this area. I'm sure that all of you
>>>> agree with me that this exercise will have a long term benefit. Generally,
>>>> tasks like this get pushed to the bottom since the immediate benefit may 
>>>> not
>>>> be apparent.
>>>>
>>>> I'd like to request the following volunteers to dedicate some time *
>>>> today* to finish off these items.
>>>>
>>>> 1. Isuru
>>>> 2. Thilina
>>>> 3. Senaka
>>>> 4. Sameera
>>>> 5. Ruwan
>>>> 6. AmilaJ
>>>> 7. Ajith
>>>> 8. Rajika
>>>> 9. Ratha
>>>> 10. Shariq
>>>> 11. Kasun
>>>> 12. Hiranya
>>>> 13. Ruchira
>>>> 14. Supun
>>>> 15. Heshan
>>>> 16. Chathuri
>>>>
>>>> Unfortunately, there are many component which do not have any
>>>> volunteers. At least the initial authors of these components should take
>>>> ownership of these components! If anybody has issues, you could use the IRC
>>>> channel to communicate your issues.
>>>>
>>>> Thanks
>>>> Azeez
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, Sep 21, 2010 at 2:09 PM, Afkham Azeez <az...@wso2.com> wrote:
>>>>
>>>>> Hi folks,
>>>>> We are planning to have $subject this Thursday at the #59 office.
>>>>> Volunteers please be in office at 9.30 AM.
>>>>>
>>>>> See:
>>>>> https://spreadsheets.google.com/a/wso2.com/ccc?key=0AnW7aoJmJW4wdGlnRGR0OVNRSFRmTHo0dHlMbHJMM0E&hl=en#gid=2
>>>>>
>>>>> Thanks
>>>>> --
>>>>> *Afkham Azeez*
>>>>> Senior Software Architect & Senior Manager; WSO2, Inc.;
>>>>> http://wso2.com,
>>>>> *
>>>>> *
>>>>> *Member; Apache Software Foundation; 
>>>>> **http://www.apache.org/*<http://www.apache.org/>
>>>>> *
>>>>> email: **az...@wso2.com* <az...@wso2.com>* 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*
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Afkham Azeez*
>>>> Senior Software Architect & Senior Manager; WSO2, Inc.; http://wso2.com
>>>> ,
>>>> *
>>>> *
>>>> *Member; Apache Software Foundation; 
>>>> **http://www.apache.org/*<http://www.apache.org/>
>>>> *
>>>> email: **az...@wso2.com* <az...@wso2.com>* 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*
>>>>
>>>>
>>>
>>>
>>> --
>>> *Afkham Azeez*
>>> Senior Software Architect & Senior Manager; WSO2, Inc.; http://wso2.com
>>> ,
>>> *
>>> *
>>> *Member; Apache Software Foundation; 
>>> **http://www.apache.org/*<http://www.apache.org/>
>>> *
>>> email: **az...@wso2.com* <az...@wso2.com>* 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*
>>>
>>>
>>> _______________________________________________
>>> Carbon-dev mailing list
>>> Carbon-dev@wso2.org
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>>
>>>
>>
>>
>> --
>> Thilina Mahesh Buddhika
>> Senior Software Engineer
>>
>> WSO2 Inc. ; http://wso2.com
>> lean . enterprise . middleware
>>
>> phone : +94 77 44 88 727
>> blog : http://blog.thilinamb.com
>>
>> _______________________________________________
>> Carbon-dev mailing list
>> Carbon-dev@wso2.org
>> https://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>
>>
>
>
> --
> Sameera Jayasoma
> Technical Lead and Product Manager, WSO2 Carbon
>
> WSO2, Inc. (http://wso2.com)
> email: same...@wso2.com
> blog: http://tech.jayasoma.org
>
> Lean . Enterprise . Middleware
>



-- 
Sameera Jayasoma
Technical Lead and Product Manager, WSO2 Carbon

WSO2, Inc. (http://wso2.com)
email: same...@wso2.com
blog: http://tech.jayasoma.org

Lean . Enterprise . Middleware
_______________________________________________
Carbon-dev mailing list
Carbon-dev@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to