mirror of
https://github.com/topjohnwu/libsu.git
synced 2024-10-07 01:03:22 +00:00
Properly handle shell check errors
This commit is contained in:
parent
7cac36171f
commit
c6dcd22612
@ -113,23 +113,25 @@ class ShellImpl extends Shell {
|
||||
|
||||
// Shell checks might get stuck indefinitely
|
||||
Future<Void> check = executor.submit(this::shellCheck);
|
||||
|
||||
try {
|
||||
check.get(timeout, TimeUnit.SECONDS);
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof IOException) {
|
||||
throw (IOException) cause;
|
||||
} else {
|
||||
throw new IOException("Unknown ExecutionException", cause);
|
||||
try {
|
||||
check.get(timeout, TimeUnit.SECONDS);
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof IOException) {
|
||||
throw (IOException) cause;
|
||||
} else {
|
||||
throw new IOException("Unknown ExecutionException", cause);
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
throw new IOException("Shell timeout", e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IOException("Shell initialization interrupted", e);
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
throw new IOException("Shell timeout", e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IOException("Shell initialization interrupted", e);
|
||||
} finally {
|
||||
} catch (IOException e) {
|
||||
executor.shutdownNow();
|
||||
release();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user