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

STORM-3170: Fixed bug to eliminate invalid file deletion #2788

Merged
merged 1 commit into from
Aug 3, 2018

Conversation

zd-project
Copy link
Contributor

@zd-project
Copy link
Contributor Author

This will affect #2754

final long fileSize = file.length();
final long lastModified = file.lastModified();
//Original implementation doesn't actually check if delete succeeded or not.
if (file.delete()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we should make this check, but won't this change make the outer while loop run again on the same files if the files couldn't be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if we should use forcedelete here directly?

@Override
public File build() {
File mockFile = super.build();
Mockito.when(mockFile.delete()).thenReturn(true);
Copy link
Contributor

@srdo srdo Aug 2, 2018

Choose a reason for hiding this comment

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

This stubbing is a little weird. It'll make the files pretend to be deleteable, but once you delete the file it'll still say it exists, and calling delete again will still return true.

Is the reason we're mocking File rather than creating temporary files for performance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm simply leveraging what's already out there. Maybe it's easier to control the behavior of a file in this way? I'll look into the implementation to see if I can alter behavior after calling #delete

Copy link
Contributor

Choose a reason for hiding this comment

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

@zd-project you can control it more fully, but it gets a little more complicated. Not a big deal but if it is causing problems it can be done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I still concern about this issue then? @revans2 @srdo

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it's just me nitpicking. We can always replace it if it becomes an issue to use in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I'll just file a minor jira then

Copy link
Contributor

@revans2 revans2 left a comment

Choose a reason for hiding this comment

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

+1

@srdo
Copy link
Contributor

srdo commented Aug 3, 2018

+1, thanks for fixing the issue with nondeleteable files. The solution looks good. Please squash and we can merge.

@revans2
Copy link
Contributor

revans2 commented Aug 3, 2018

Still +1

@asfgit asfgit merged commit fe94434 into apache:master Aug 3, 2018
asfgit pushed a commit that referenced this pull request Aug 3, 2018
… STORM-3170

STORM-3170: Fixed bug to eliminate invalid file deletion

This closes #2788
@zd-project zd-project deleted the STORM-3170 branch August 3, 2018 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants