Skip to content

Commit

Permalink
8327096: (fc) java/nio/channels/FileChannel/Size.java fails on partit…
Browse files Browse the repository at this point in the history
…ion incapable of creating large files

Backport-of: 94b4ed5766381fdb922f9aaba02201a7fb735cb3
  • Loading branch information
Sonia Zaldana Calles authored and jerboaa committed Apr 23, 2024
1 parent 324cef1 commit 031acf1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test/jdk/java/nio/channels/FileChannel/Size.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,15 +24,18 @@
/* @test
* @bug 4563125
* @summary Test size method of FileChannel
* @library /test/lib
* @run main/othervm Size
* @key randomness
*/

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.
Expand Down Expand Up @@ -65,6 +68,8 @@ private static void testSmallFile() throws Exception {
// 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()) {
Expand All @@ -75,8 +80,15 @@ private static void testLargeFile() throws Exception {
+ "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();
}

/**
Expand Down

1 comment on commit 031acf1

@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.