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
2121 * questions.
2222 */
2323
24- /**
24+ /*
2525 * @test
2626 * @bug 8137121 8137230
2727 * @summary (fc) Infinite loop FileChannel.truncate
3131 */
3232
3333import java .nio .ByteBuffer ;
34- import java .nio .channels .FileChannel ;
3534import java .nio .channels .ClosedByInterruptException ;
35+ import java .nio .channels .FileChannel ;
3636import java .nio .file .Files ;
3737import java .nio .file .Path ;
38- import static java .nio .file .StandardOpenOption .*;
3938import java .util .concurrent .TimeUnit ;
39+ import static java .nio .file .StandardOpenOption .*;
4040import static jdk .test .lib .Utils .adjustTimeout ;
4141
4242public 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