Bug 1575875 - Java API Files.copy cause an incomplete file, and not throw exceptions.
Summary: Java API Files.copy cause an incomplete file, and not throw exceptions.
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: java-1.8.0-openjdk
Version: 7.4
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Andrew John Hughes
QA Contact: zzambers
Depends On:
TreeView+ depends on / blocked
Reported: 2018-05-08 07:20 UTC by sfu@redhat.com
Modified: 2018-11-15 20:14 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2018-11-15 20:14:39 UTC
Target Upstream Version:

Attachments (Terms of Use)

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"
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 /home/test/source
mount -t nfs -o rw,bg,soft,intr,timeo=300,vers=4  /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:

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.

Note You need to log in before you can comment on or make changes to this bug.