Joerg Heinicke schrieb:
> On 12.07.2007 01:37, [EMAIL PROTECTED] wrote:
>> Author: felixk
>> Date: Wed Jul 11 22:37:32 2007
>> New Revision: 555496
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=555496
>> Log:
>> Make sure, they finally are closed
>
> Hi Felix,
>
> the streams are now closed twice since close() is also inside try
> block. Also if outStream.close() fails with an exception instream will
> remain open.

Ups, I forget to delete after copying.

Thanks Joerg
>
> Joerg
>
>> ==============================================================================
>>
>> ---
>> cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/DeploymentUtil.java
>> (original)
>> +++
>> cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/DeploymentUtil.java
>> Wed Jul 11 22:37:32 2007
>> @@ -67,11 +67,23 @@
>>                  final File out = new File(fileName);
>>                  // create directory
>>                  out.getParentFile().mkdirs();
>> -                final InputStream inStream =
>> jarFile.getInputStream(entry);
>> -                final OutputStream outStream = new
>> FileOutputStream(out);
>> -                IOUtils.copy(inStream, outStream);
>> -                inStream.close();
>> -                outStream.close();
>> +                +                InputStream inStream = null;
>> +                OutputStream outStream = null;
>> +                try {
>> +                    inStream = jarFile.getInputStream(entry);
>> +                    outStream = new FileOutputStream(out);
>> +                    IOUtils.copy(inStream, outStream);
>> +                    inStream.close();
>> +                    outStream.close();
>> +                } finally {
>> +                    if (outStream != null) {
>> +                        outStream.close();
>> +                    }
>> +                    if (inStream != null) {
>> +                        inStream.close();
>> +                    }
>> +                }
>>              }
>>          }
>>      }
>>
>>
>

Reply via email to