< prev index next >

src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java

Print this page
*** 33,15 ***
  import java.nio.file.LinkOption;
  import java.nio.file.LinkPermission;
  import java.nio.file.StandardCopyOption;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.TimeUnit;
! 
  import static sun.nio.fs.UnixNativeDispatcher.*;
  import static sun.nio.fs.UnixConstants.*;
  
- 
  /**
   * Unix implementation of Path#copyTo and Path#moveTo methods.
   */
  
  class UnixCopyFile {
--- 33,14 ---
  import java.nio.file.LinkOption;
  import java.nio.file.LinkPermission;
  import java.nio.file.StandardCopyOption;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.TimeUnit;
! import jdk.internal.misc.Blocker;
  import static sun.nio.fs.UnixNativeDispatcher.*;
  import static sun.nio.fs.UnixConstants.*;
  
  /**
   * Unix implementation of Path#copyTo and Path#moveTo methods.
   */
  
  class UnixCopyFile {

*** 249,11 ***
              // set to true when file and attributes copied
              boolean complete = false;
              try {
                  // transfer bytes to target file
                  try {
!                     transfer(fo, fi, addressToPollForCancel);
                  } catch (UnixException x) {
                      x.rethrowAsIOException(source, target);
                  }
                  // copy owner/permissions
                  if (flags.copyPosixAttributes) {
--- 248,17 ---
              // set to true when file and attributes copied
              boolean complete = false;
              try {
                  // transfer bytes to target file
                  try {
!                     int dst = fo;
+                     int src = fi;
+                     if (Thread.currentThread().isVirtual()) {
+                         Blocker.managedBlock(() -> transfer(dst, src, addressToPollForCancel));
+                     } else {
+                         transfer(dst, src, addressToPollForCancel);
+                     }
                  } catch (UnixException x) {
                      x.rethrowAsIOException(source, target);
                  }
                  // copy owner/permissions
                  if (flags.copyPosixAttributes) {
< prev index next >