privatevolatile HikariPool pool; @Override public Connection getConnection()throws SQLException{ if (isClosed()) { thrownew SQLException("HikariDataSource " + this + " has been closed."); }
if (fastPathPool != null) { return fastPathPool.getConnection(); }
// See http://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java HikariPool result = pool; if (result == null) { synchronized (this) { result = pool; if (result == null) { validate(); LOGGER.info("{} - Starting...", getPoolName()); try { pool = result = new HikariPool(this); this.seal(); } catch (PoolInitializationException pie) { if (pie.getCause() instanceof SQLException) { throw (SQLException) pie.getCause(); } else { throw pie; } } LOGGER.info("{} - Start completed.", getPoolName()); } } }