From 94b4ed5766381fdb922f9aaba02201a7fb735cb3 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 12 Mar 2024 18:06:45 +0000 Subject: [PATCH] 8327096: (fc) java/nio/channels/FileChannel/Size.java fails on partition incapable of creating large files Reviewed-by: djelinski --- .../java/nio/channels/FileChannel/Size.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/jdk/java/nio/channels/FileChannel/Size.java b/test/jdk/java/nio/channels/FileChannel/Size.java index fd6e744f03f..2db86a8089e 100644 --- a/test/jdk/java/nio/channels/FileChannel/Size.java +++ b/test/jdk/java/nio/channels/FileChannel/Size.java @@ -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(); } /**