On 14 August 2014 06:38,  <bode...@apache.org> wrote:
> Author: bodewig
> Date: Thu Aug 14 05:38:59 2014
> New Revision: 1617882
>
> URL: http://svn.apache.org/r1617882
> Log:
> deal with files without parent
>
> Modified:
>     
> commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java
>
> Modified: 
> commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java?rev=1617882&r1=1617881&r2=1617882&view=diff
> ==============================================================================
> --- 
> commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java
>  (original)
> +++ 
> commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java
>  Thu Aug 14 05:38:59 2014
> @@ -73,7 +73,7 @@ public class CLI {
>
>                  System.out.println("extracting to " + outFile);
>                  File parent = outFile.getParentFile();
> -                if (!parent.exists() && !parent.mkdirs()) {
> +                if (parent != null && !parent.exists() && !parent.mkdirs()) {

I think there is a window between the existence check and the mkdirs.
The mkdirs() will return false if something else creates the directory(s).

It might work better as

if (parent != null && !parent.mkdirs() && !parent.isDirectory()) {

See also: https://issues.apache.org/jira/browse/IO-280


>                      throw new IOException("Cannot create " + parent);
>                  }
>                  FileOutputStream fos = new FileOutputStream(outFile);
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to