Skip to content

Commit 031acf1

Browse files
Sonia Zaldana Callesjerboaa
authored andcommitted
8327096: (fc) java/nio/channels/FileChannel/Size.java fails on partition incapable of creating large files
Backport-of: 94b4ed5766381fdb922f9aaba02201a7fb735cb3
1 parent 324cef1 commit 031acf1

File tree

1 file changed

+15
-3
lines changed
  • test/jdk/java/nio/channels/FileChannel

1 file changed

+15
-3
lines changed

test/jdk/java/nio/channels/FileChannel/Size.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,15 +24,18 @@
2424
/* @test
2525
* @bug 4563125
2626
* @summary Test size method of FileChannel
27+
* @library /test/lib
2728
* @run main/othervm Size
2829
* @key randomness
2930
*/
3031

3132
import java.io.*;
3233
import java.nio.MappedByteBuffer;
3334
import java.nio.channels.*;
35+
import java.nio.file.FileStore;
36+
import java.nio.file.Path;
3437
import java.util.Random;
35-
38+
import jtreg.SkippedException;
3639

3740
/**
3841
* Testing FileChannel's size method.
@@ -65,6 +68,8 @@ private static void testSmallFile() throws Exception {
6568
// Test for bug 4563125
6669
private static void testLargeFile() throws Exception {
6770
File largeFile = new File("largeFileTest");
71+
largeFile.deleteOnExit();
72+
6873
long testSize = ((long)Integer.MAX_VALUE) * 2;
6974
initTestFile(largeFile, 10);
7075
try (FileChannel fc = new RandomAccessFile(largeFile, "rw").getChannel()) {
@@ -75,8 +80,15 @@ private static void testLargeFile() throws Exception {
7580
+ "Expect size " + (testSize + 10)
7681
+ ", actual size " + fc.size());
7782
}
83+
} catch (IOException ioe) {
84+
if ("File too large".equals(ioe.getMessage())) {
85+
Path p = largeFile.toPath();
86+
FileStore store = p.getFileSystem().provider().getFileStore(p);
87+
if ("msdos".equals(store.type()))
88+
throw new SkippedException("file too big for FAT32");
89+
}
90+
throw ioe;
7891
}
79-
largeFile.deleteOnExit();
8092
}
8193

8294
/**

0 commit comments

Comments
 (0)