Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

This PR moves the file open position to prevent opened file leakage more robustly.

@dongjoon-hyun dongjoon-hyun changed the title [ORC-301] extractFileTail should open a file in try statement ORC-301. extractFileTail should open a file in try statement Feb 14, 2018
@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Feb 14, 2018

Hi, @omalley and @prasanthj .
Could you review this PR?

OrcProto.PostScript ps;
OrcProto.FileTail.Builder fileTailBuilder = OrcProto.FileTail.newBuilder();
long modificationTime;
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe replace with try-with-resource 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.

Thank you for review, @prasanthj .
Ya. I thought to use try-with-resource first, but it needs more change to print out the log at Line 610.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is the minimal change while keeping the current behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

Line 610 doesn't add much value as close() will throw IOException anyway which should be sufficient to know the reason.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, you mean it's okay to remove the following in this PR, right?

catch (IOException ex) {
  LOG.error("Failed to close the file after another error", ex);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's right.

@dongjoon-hyun
Copy link
Member Author

Thank you, @prasanthj . I updated according to your advice.

@prasanthj
Copy link
Contributor

lgtm, +1

@dongjoon-hyun
Copy link
Member Author

Thank you so much, @prasanthj !

@asfgit asfgit closed this in 28e88da Feb 16, 2018
asfgit pushed a commit that referenced this pull request Feb 16, 2018
Fixes #218

Signed-off-by: Prasanth Jayachandran <prasanthj@apache.org>
@dongjoon-hyun dongjoon-hyun deleted the ORC-301 branch February 16, 2018 07:54
@dongjoon-hyun
Copy link
Member Author

Thank you for merging, @prasanthj !

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.

2 participants