You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/11/04 11:11:57 UTC

svn commit: r1538541 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/impl/io/DirFile.java

Author: kahatlen
Date: Mon Nov  4 10:11:57 2013
New Revision: 1538541

URL: http://svn.apache.org/r1538541
Log:
DERBY-6396: NullPointerException in DirFile

Merged fix from trunk (revision 1537394).

Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/DirFile.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1537394

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/DirFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/DirFile.java?rev=1538541&r1=1538540&r2=1538541&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/DirFile.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/io/DirFile.java Mon Nov  4 10:11:57 2013
@@ -281,11 +281,21 @@ class DirFile extends File implements St
      */
     public boolean deleteAll()
     {
-        if( !exists())
+        // Nothing to do if the file doesn't exist.
+        if (!exists()) {
             return false;
-        if( isDirectory())
+        }
+
+        // If the file is a directory, delete its contents recursively.
+        // File.list() will return null if it is not a directory, or if the
+        // contents of the directory cannot be read. Skip the recursive step
+        // in both of those cases. If it turns out that the file in fact is a
+        // directory, and we couldn't delete its contents, the delete() call
+        // at the end of this method will return false to notify the caller
+        // that the directory could not be deleted.
+        String[] childList = super.list();
+        if (childList != null)
         {
-            String[] childList = super.list();
             String parentName = getPath();
             for( int i = 0; i < childList.length; i++)
             {
@@ -296,6 +306,9 @@ class DirFile extends File implements St
                     return false;
             }
         }
+
+        // Finally, attempt to delete the file (or directory) and return
+        // whether or not we succeeded.
         return delete();
     } // end of deleteAll