Skip to content

Commit

Permalink
8272047: java/nio/channels/FileChannel/Transfer2GPlus.java failed wit…
Browse files Browse the repository at this point in the history
…h Unexpected transfer size: 2147418112

Reviewed-by: naoto, alanb
  • Loading branch information
Brian Burkhalter committed Aug 9, 2021
1 parent 41dc795 commit b53828b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 0 additions & 2 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,6 @@ java/nio/channels/AsynchronousSocketChannel/StressLoopback.java 8211851 aix-ppc6

java/nio/channels/Selector/Wakeup.java 6963118 windows-all

java/nio/channels/FileChannel/Transfer2GPlus.java 8272047 linux-aarch64

############################################################################

# jdk_rmi
Expand Down
23 changes: 13 additions & 10 deletions test/jdk/java/nio/channels/FileChannel/Transfer2GPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import jdk.test.lib.Platform;

public class Transfer2GPlus {
private static final int LINUX_MAX_TRANSFER_SIZE = 0x7ffff000;

private static final long BASE = (long)Integer.MAX_VALUE;
private static final int EXTRA = 1024;
private static final long LENGTH = BASE + EXTRA;
Expand Down Expand Up @@ -83,22 +81,27 @@ private static void testToFileChannel(Path src, byte[] expected)
try (FileChannel srcCh = FileChannel.open(src)) {
try (FileChannel dstCh = FileChannel.open(dst,
StandardOpenOption.READ, StandardOpenOption.WRITE)) {
long n;
if ((n = srcCh.transferTo(0, LENGTH, dstCh)) < LENGTH) {
long total = 0L;
if ((total = srcCh.transferTo(0, LENGTH, dstCh)) < LENGTH) {
if (!Platform.isLinux())
throw new RuntimeException("Transfer too small: " + n);
throw new RuntimeException("Transfer too small: " + total);

if (n != 0x7ffff000)
throw new RuntimeException("Unexpected transfer size: " + n);
if ((n += srcCh.transferTo(n, LENGTH, dstCh)) != LENGTH)
throw new RuntimeException("Unexpected total size: " + n);
// If this point is reached we're on Linux which cannot
// transfer all LENGTH bytes in one call to sendfile(2),
// so loop to get the rest.
do {
long n = srcCh.transferTo(total, LENGTH, dstCh);
if (n == 0)
break;
total += n;
} while (total < LENGTH);
}

if (dstCh.size() < LENGTH)
throw new RuntimeException("Target file too small: " +
dstCh.size() + " < " + LENGTH);

System.out.println("Transferred " + n + " bytes");
System.out.println("Transferred " + total + " bytes");

dstCh.position(BASE);
ByteBuffer bb = ByteBuffer.allocate(EXTRA);
Expand Down

1 comment on commit b53828b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.