You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Joerg Heinicke <jo...@gmx.de> on 2007/07/12 14:02:43 UTC

Re: svn commit: r555496 - /cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/DeploymentUtil.java

On 12.07.2007 01:37, felixk@apache.org 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.

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();
> +                    }
> +                }
>              }
>          }
>      }
> 
> 

Re: svn commit: r555496 - /cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/DeploymentUtil.java

Posted by Felix Knecht <fe...@apache.org>.
Joerg Heinicke schrieb:
> On 12.07.2007 01:37, felixk@apache.org 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();
>> +                    }
>> +                }
>>              }
>>          }
>>      }
>>
>>
>


Re: svn commit: r555496 - /cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/DeploymentUtil.java

Posted by Joerg Heinicke <jo...@gmx.de>.
On 12.07.2007 08:20, Felix Knecht wrote:
> Joerg Heinicke schrieb:
> 
> My conclusion must be:
> NEVER getting up, committing the dreams I had during sleep and then
> getting fully awake ...

Oh, you dream of unclosed streams? :-)

Joerg

Re: svn commit: r555496 - /cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/DeploymentUtil.java

Posted by Felix Knecht <fe...@apache.org>.
Joerg Heinicke schrieb:

My conclusion must be:
NEVER getting up, committing the dreams I had during sleep and then
getting fully awake ...


> 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.
>
> Joerg
>