Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MCLEAN-124] Leverage Files.delete(Path) API to provide more accurate reason in case of failure #84

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

slawekjaranowski
Copy link
Member

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MCLEAN-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MCLEAN-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

} catch (InterruptedException e2) {
exception.addSuppressed(e2);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused. If the thread has already thrown an interrupted exception, why are you interrupting it again? Are these two different threads?

Copy link
Member Author

Choose a reason for hiding this comment

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

As we don't re-throw InterruptedException here we should set interrupted flag agin

http://www.javapractices.com/topic/TopicAction.do?Id=251

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that's what that says. It suggests resetting the interrupted flag if you don;t handle the exception, but here it's handled by throwing an IOException.

And now that I look at this, is that even right? We're sleeping between retries, the sleep is interrupted, so we cancel all the retries and throw an IOException instead of returning. I guess that makes sense, but at this point the interrupt has been handled so it doesn't seem like the current thread should still have its interrupt flag set.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok remove it.

try {
Files.deleteIfExists(file);
} catch (IOException e) {
return e;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an unidiomatic pattern for Java. I would expect this to simply throw the exception and have that case handled in a catch block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe can be designed in better way, but please consider that it is moved code from 3.x branch to master.

} catch (InterruptedException e2) {
exception.addSuppressed(e2);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that's what that says. It suggests resetting the interrupted flag if you don;t handle the exception, but here it's handled by throwing an IOException.

And now that I look at this, is that even right? We're sleeping between retries, the sleep is interrupted, so we cancel all the retries and throw an IOException instead of returning. I guess that makes sense, but at this point the interrupt has been handled so it doesn't seem like the current thread should still have its interrupt flag set.

@slawekjaranowski slawekjaranowski merged commit 282cf61 into apache:master Feb 2, 2025
11 checks passed
@slawekjaranowski slawekjaranowski deleted the cp-60 branch February 2, 2025 20:32
@github-actions github-actions bot added this to the 4.0.0-beta-2 milestone Feb 2, 2025
@jira-importer
Copy link
Collaborator

Resolve #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants