Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8272964: java/nio/file/Files/InterruptCopy.java fails with java.lang.…
…RuntimeException: Copy was not interrupted

Reviewed-by: dfuchs
  • Loading branch information
Brian Burkhalter committed Aug 27, 2021
1 parent a033aa5 commit dfeb413
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/jdk/java/nio/file/Files/InterruptCopy.java
Expand Up @@ -45,7 +45,6 @@ public class InterruptCopy {

private static final long FILE_SIZE_TO_COPY = 1024L * 1024L * 1024L;
private static final int INTERRUPT_DELAY_IN_MS = 50;
private static final int DURATION_MAX_IN_MS = 3*INTERRUPT_DELAY_IN_MS;
private static final int CANCEL_DELAY_IN_MS = 10;

public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -109,8 +108,15 @@ public void run() {
long theEnd = System.currentTimeMillis();
System.out.printf("Done copying at %d ms...%n", theEnd);
long duration = theEnd - theBeginning;
if (duration > DURATION_MAX_IN_MS)
throw new RuntimeException("Copy was not interrupted");

// If the copy was interrupted the target file should have been
// deleted, so if the file does not exist, then the copy must
// have been interrupted without throwing an exception; if the
// file exists, then the copy finished before being interrupted
// so not throwing an exception is not considered a failure
if (Files.notExists(target))
throw new RuntimeException("Copy was not interrupted in " +
duration + " ms");
} catch (IOException e) {
boolean interrupted = Thread.interrupted();
if (!interrupted)
Expand Down

5 comments on commit dfeb413

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on dfeb413 Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr the backport was successfully created on the branch TheRealMDoerr-backport-dfeb4132 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit dfeb4132 from the openjdk/jdk repository.

The commit being backported was authored by Brian Burkhalter on 27 Aug 2021 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev TheRealMDoerr-backport-dfeb4132:TheRealMDoerr-backport-dfeb4132
$ git checkout TheRealMDoerr-backport-dfeb4132
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev TheRealMDoerr-backport-dfeb4132

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on dfeb413 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on dfeb413 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-dfeb4132 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit dfeb4132 from the openjdk/jdk repository.

The commit being backported was authored by Brian Burkhalter on 27 Aug 2021 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-dfeb4132:GoeLin-backport-dfeb4132
$ git checkout GoeLin-backport-dfeb4132
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-dfeb4132

Please sign in to comment.