gengliangwang commented on pull request #32983:
URL: https://github.com/apache/spark/pull/32983#issuecomment-864588194


   Another safe fix is that we have our own version of `copy` which is the same 
as the current Hadoop 3.3.1 code, instead of calling `FileUtil.copy`. 
   
   ```
     /** Copy files between FileSystems. */
     public static boolean copy(FileSystem srcFS, FileStatus srcStatus,
                                FileSystem dstFS, Path dst,
                                boolean deleteSource,
                                boolean overwrite,
                                Configuration conf) throws IOException {
       Path src = srcStatus.getPath();
       dst = checkDest(src.getName(), dstFS, dst, overwrite);
       if (srcStatus.isDirectory()) {
         checkDependencies(srcFS, src, dstFS, dst);
         if (!dstFS.mkdirs(dst)) {
           return false;
         }
         FileStatus contents[] = srcFS.listStatus(src);
         for (int i = 0; i < contents.length; i++) {
           copy(srcFS, contents[i], dstFS,
                new Path(dst, contents[i].getPath().getName()),
                deleteSource, overwrite, conf);
         }
       } else {
         InputStream in=null;
         OutputStream out = null;
         try {
           in = srcFS.open(src);
           out = dstFS.create(dst, overwrite);
           IOUtils.copyBytes(in, out, conf, true);
         } catch (IOException e) {
           IOUtils.closeStream(out);
           IOUtils.closeStream(in);
           throw e;
         }
       }
       if (deleteSource) {
         return srcFS.delete(src, true);
       } else {
         return true;
       }
   
     }
   ```
   
   We can remove this hack after we find out the root cause or we upgrade to a 
newer version with a fix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to