Skip to content

Commit fcdcff0

Browse files
author
SendaoYan
committedFeb 13, 2025
8346972: Test java/nio/channels/FileChannel/LoopingTruncate.java fails sometimes with IOException: There is not enough space on the disk
Backport-of: a07d784919ae232a890bf79de27b8623e294ad20
1 parent 9eb9ce4 commit fcdcff0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
 

‎test/jdk/java/nio/channels/FileChannel/LoopingTruncate.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, 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
@@ -21,7 +21,7 @@
2121
* questions.
2222
*/
2323

24-
/**
24+
/*
2525
* @test
2626
* @bug 8137121 8137230
2727
* @summary (fc) Infinite loop FileChannel.truncate
@@ -31,12 +31,12 @@
3131
*/
3232

3333
import java.nio.ByteBuffer;
34-
import java.nio.channels.FileChannel;
3534
import java.nio.channels.ClosedByInterruptException;
35+
import java.nio.channels.FileChannel;
3636
import java.nio.file.Files;
3737
import java.nio.file.Path;
38-
import static java.nio.file.StandardOpenOption.*;
3938
import java.util.concurrent.TimeUnit;
39+
import static java.nio.file.StandardOpenOption.*;
4040
import static jdk.test.lib.Utils.adjustTimeout;
4141

4242
public class LoopingTruncate {
@@ -48,7 +48,10 @@ public class LoopingTruncate {
4848
static long TIMEOUT = adjustTimeout(20_000);
4949

5050
public static void main(String[] args) throws Throwable {
51-
Path path = Files.createTempFile("LoopingTruncate.tmp", null);
51+
// Intentionally opting out from the default `java.io.tmpdir`.
52+
// It occasionally lacks the sufficient disk space this test needs.
53+
Path pathDir = Path.of(System.getProperty("user.dir"));
54+
Path path = Files.createTempFile(pathDir, "LoopingTruncate.tmp", null);
5255
try (FileChannel fc = FileChannel.open(path, CREATE, WRITE)) {
5356
fc.position(FATEFUL_SIZE + 1L);
5457
System.out.println(" Writing large file...");

0 commit comments

Comments
 (0)