-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
GH-3078: Use Hadoop FileSystem.openFile() to open files #3079
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,29 @@ public static <T> T awaitFuture(final Future<T> future, final long timeout, fina | |
} | ||
} | ||
|
||
/** | ||
* Given a future, evaluate it. | ||
* <p> | ||
* Any exception generated in the future is | ||
* extracted and rethrown. | ||
* </p> | ||
* @param future future to evaluate | ||
* @param <T> type of the result. | ||
* @return the result, if all went well. | ||
* @throws InterruptedIOException future was interrupted | ||
* @throws IOException if something went wrong | ||
* @throws RuntimeException any nested RTE thrown | ||
*/ | ||
public static <T> T awaitFuture(final Future<T> future) | ||
throws InterruptedIOException, IOException, RuntimeException { | ||
try { | ||
return future.get(); | ||
} catch (InterruptedException e) { | ||
throw (InterruptedIOException) new InterruptedIOException(e.toString()).initCause(e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Why the cast? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, missed that, thanks! |
||
} catch (ExecutionException e) { | ||
throw unwrapInnerException(e); | ||
} | ||
} | ||
/** | ||
* From the inner cause of an execution exception, extract the inner cause | ||
* to an IOException, raising Errors immediately. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we at least log the original exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. at debug? I'm never a fan of excessively noisy libraries as they ruin the lives of people downstream, especially if messages for developers end up being printed in user logs far too often. In fact, I'm not above dynamically patching log levels to shut those libraries up (HADOOP-19272)...
stack trace then, debug.
error text itself? Probably the same unless there's a desire to log exactly once during the life of a process, which could be done trivially
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with any solutions just did not want to loose the exception may occur.
Another idea I've had is to catch the potential exception may come out of this line (let's call it
e2
) and add the previously caughte
as suppressed toe2
, then re-throw. But it might be an overkill since this code path "near-impossible" to be taken.