8327096: (fc) java/nio/channels/FileChannel/Size.java fails on partition incapable of creating large files

Reviewed-by: djelinski
This commit is contained in:
Brian Burkhalter 2024-03-12 18:06:45 +00:00
parent b9c3dc3b47
commit 94b4ed5766

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
/* @test
* @bug 4563125
* @summary Test size method of FileChannel
* @library /test/lib
* @run main/othervm Size
* @key randomness
*/
@ -31,8 +32,10 @@
import java.io.*;
import java.nio.MappedByteBuffer;
import java.nio.channels.*;
import java.nio.file.FileStore;
import java.nio.file.Path;
import java.util.Random;
import jtreg.SkippedException;
/**
* Testing FileChannel's size method.
@ -65,6 +68,8 @@ public class Size {
// Test for bug 4563125
private static void testLargeFile() throws Exception {
File largeFile = new File("largeFileTest");
largeFile.deleteOnExit();
long testSize = ((long)Integer.MAX_VALUE) * 2;
initTestFile(largeFile, 10);
try (FileChannel fc = new RandomAccessFile(largeFile, "rw").getChannel()) {
@ -75,8 +80,15 @@ public class Size {
+ "Expect size " + (testSize + 10)
+ ", actual size " + fc.size());
}
} catch (IOException ioe) {
if ("File too large".equals(ioe.getMessage())) {
Path p = largeFile.toPath();
FileStore store = p.getFileSystem().provider().getFileStore(p);
if ("msdos".equals(store.type()))
throw new SkippedException("file too big for FAT32");
}
throw ioe;
}
largeFile.deleteOnExit();
}
/**