Skip to content

Commit

Permalink
Backport 4e0ffda5b1d82449d2d6f639be7641b69d6cb520
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Feb 7, 2025
1 parent f1b1fd4 commit e83ddaf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/jdk/java/nio/channels/FileChannel/LoopingTruncate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, 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 @@ -21,7 +21,7 @@
* questions.
*/

/**
/*
* @test
* @bug 8137121 8137230
* @summary (fc) Infinite loop FileChannel.truncate
Expand All @@ -31,12 +31,12 @@
*/

import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import static java.nio.file.StandardOpenOption.*;
import java.util.concurrent.TimeUnit;
import static java.nio.file.StandardOpenOption.*;
import static jdk.test.lib.Utils.adjustTimeout;

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

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

0 comments on commit e83ddaf

Please sign in to comment.