Bug 1575875

Summary: Java API Files.copy cause an incomplete file, and not throw exceptions.
Product: Red Hat Enterprise Linux 7 Reporter: sfu <sfu>
Component: java-1.8.0-openjdkAssignee: Andrew John Hughes <ahughes>
Status: CLOSED WONTFIX QA Contact: zzambers
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: agiertli, ahughes, cww, jvanek
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-15 20:14:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sfu@redhat.com 2018-05-08 07:20:42 UTC
Description of problem:
With openjdk8, Files.copy cause an incomplete file,and not throw any exception.
copy a file from a nfs mount directory A to a nfs mount directory B. 
if B has no enough space, the FileCopy.java will not fail,and not throw any exception.Just left an incomplete file there.


Version-Release number of selected component (if applicable):
RHEL 7.4 + NFS
openjdk version "1.8.0_171"
--nfs-server-host: 
vim /etc/exports:
/home/test/ * (rw,sync,no_wdelay,no_root_squash)
--nfs client:
mount command:
mount -t nfs -o rw,bg,soft,intr,timeo=300,vers=4 10.11.12.13:/home/test/source /home/test/source
mount -t nfs -o rw,bg,soft,intr,timeo=300,vers=4 10.11.12.13:/home/test/target  /home/test/target

Java code (FileCopy.java) like:
~~~~~~~~~~~~~~~~~~~~~~
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

/**
 */
public class FileCopy {
    public static  void main(String[] args) throws IOException {

        //the source file size is 190mb
        String source ="/home/test/source/190MB.txt";

        //the target dir has 90mb  free space
        String target = "/home/test/target/tar.txt";
        Path sourcePath = Paths.get(source);
        Path targetPath = Paths.get(target);

        Files.copy(sourcePath,targetPath, StandardCopyOption.COPY_ATTRIBUTES);

    }
}
~~~~~~~~~~~~~~~~~~~~~~


How reproducible:
Always


Steps to Reproduce:
1.mount a nfs dir
2.execute java class

Actual results:
No error or exception throw by java,just left a incomplete file

Expected results:
Java throw exception like:
Exception in thread "main" java.nio.file.FileSystemException: /root/file2 -> /test/file2.tar: Input/output error
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixCopyFile.copyFile(UnixCopyFile.java:253)
	at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:581)
	at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)
	at java.nio.file.Files.copy(Files.java:1274)
	at FileCopy.main(FileCopy.java:20)

Additional info:

Just happened in nfs dir.