@Test(expected = ProcessException.class) public void testGetConnectionSqlException() throws SQLException { SQLException sqlException = new SQLException("bad sql"); when(basicDataSource.getConnection()).thenThrow(sqlException); try { hive3ConnectionPool.getConnection(); } catch (ProcessException e) { assertEquals(sqlException, e.getCause()); throw e; } }
@Override public Connection getConnection() throws ProcessException { try { if (ugi != null) { try { return ugi.doAs((PrivilegedExceptionAction<Connection>) () -> dataSource.getConnection()); } catch (UndeclaredThrowableException e) { Throwable cause = e.getCause(); if (cause instanceof SQLException) { throw (SQLException) cause; } else { throw e; } } } else { getLogger().info("Simple Authentication"); return dataSource.getConnection(); } } catch (SQLException | IOException | InterruptedException e) { getLogger().error("Error getting Hive connection", e); throw new ProcessException(e); } }
Hive3ConnectionPool extends AbstractControllerService implements Hive3DBCPService { @Override public Connection getConnection() throws ProcessException { try { if (ugi != null) { try { return ugi.doAs((PrivilegedExceptionAction<Connection>) () -> dataSource.getConnection()); } catch (UndeclaredThrowableException e) { Throwable cause = e.getCause(); if (cause instanceof SQLException) { throw (SQLException) cause; } else { throw e; } } } else { getLogger().info("Simple Authentication"); return dataSource.getConnection(); } } catch (SQLException | IOException | InterruptedException e) { getLogger().error("Error getting Hive connection", e); throw new ProcessException(e); } } }
Hive3ConnectionPool extends AbstractControllerService implements Hive3DBCPService { @Override public Connection getConnection() throws ProcessException { try { if (ugi != null) { try { return ugi.doAs((PrivilegedExceptionAction<Connection>) () -> dataSource.getConnection()); } catch (UndeclaredThrowableException e) { Throwable cause = e.getCause(); if (cause instanceof SQLException) { throw (SQLException) cause; } else { throw e; } } } else { getLogger().info("Simple Authentication"); return dataSource.getConnection(); } } catch (SQLException | IOException | InterruptedException e) { getLogger().error("Error getting Hive connection", e); throw new ProcessException(e); } }  }
Hive3ConnectionPool extends AbstractControllerService implements Hive3DBCPService { @Override public Connection getConnection() throws ProcessException { try { if (ugi != null) { try { return ugi.doAs((PrivilegedExceptionAction<Connection>) () -> dataSource.getConnection()); } catch (UndeclaredThrowableException e) { Throwable cause = e.getCause(); if (cause instanceof SQLException) { throw (SQLException) cause; } else { throw e; } } } else { getLogger().info("Simple Authentication"); return dataSource.getConnection(); } } catch (SQLException | IOException | InterruptedException e) { getLogger().error("Error getting Hive connection", e); throw new ProcessException(e); } }  @OnEnabled void onConfigured(final ConfigurationContext context); @OnDisabled void shutdown(); @Override Connection getConnection(); @Override String toString(); @Override String getConnectionURL(); }
Hive3ConnectionPool extends AbstractControllerService implements Hive3DBCPService { @Override public Connection getConnection() throws ProcessException { try { if (ugi != null) { try { return ugi.doAs((PrivilegedExceptionAction<Connection>) () -> dataSource.getConnection()); } catch (UndeclaredThrowableException e) { Throwable cause = e.getCause(); if (cause instanceof SQLException) { throw (SQLException) cause; } else { throw e; } } } else { getLogger().info("Simple Authentication"); return dataSource.getConnection(); } } catch (SQLException | IOException | InterruptedException e) { getLogger().error("Error getting Hive connection", e); throw new ProcessException(e); } }  @OnEnabled void onConfigured(final ConfigurationContext context); @OnDisabled void shutdown(); @Override Connection getConnection(); @Override String toString(); @Override String getConnectionURL();  }