future = executor.submit(task);
future.get(timeoutInSeconds, TimeUnit.SECONDS);
} catch (ExecutionException ex) {
connection.close();
if (ex.getCause() instanceof BootstrapException) {
throw new OpenOfficeException("Failed to connect to open office. Please check open office path " + openOfficePath, ex);
}
throw new RuntimeException(ex.getCause());
} catch (Throwable ex) {
connection.close();
if (ex.getCause() instanceof BootstrapException) {
throw new OpenOfficeException("Failed to connect to open office. Please check open office path " + openOfficePath, ex);
}
throw new OpenOfficeException(ex);
} finally {
if (future != null) {
future.cancel(true);
}
releaseConnection(connection);