You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2014/08/14 07:38:59 UTC

svn commit: r1617882 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java

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()) {
                     throw new IOException("Cannot create " + parent);
                 }
                 FileOutputStream fos = new FileOutputStream(outFile);



Re: svn commit: r1617882 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java

Posted by sebb <se...@gmail.com>.
On 14 August 2014 06:38,  <bo...@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-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org