Source:
public void afterPropertiesSet() throws Exception { HsqlProperties configProps = serverProperties != null ? new HsqlProperties(serverProperties) : new HsqlProperties(); ServerConfiguration.translateDefaultDatabaseProperty(configProps); server = new org.hsqldb.Server(); server.setLogWriter(null); server.setRestartOnShutdown(false); server.setNoSystemExit(true); server.setProperties(configProps); log.debug("HSQL Database path: " + server.getDatabasePath(0, true)); log.info("Starting HSQL Server database '" + server.getDatabaseName(0, true) + "' listening on port: " + server.getPort()); int tries = 0; do { server.start(); if (server.getState() == ServerConstants.SERVER_STATE_ONLINE) { break; } Thread.sleep(1000); if (server.getState() == ServerConstants.SERVER_STATE_ONLINE) { break; } Throwable t = server.getServerError(); if (t instanceof SocketException && "Invalid argument".equals(t.getMessage()) && ++tries < 5) { long fileCount = getOpenFileDescriptorCount(); log.debug(String.format( "Caught SocketException (likely due to excessive file descriptors open; current count: %d)", fileCount), t); long timeout = System.currentTimeMillis() + 5000; while (System.currentTimeMillis() < timeout && fileCount > 1024) { Thread.sleep(500); fileCount = getOpenFileDescriptorCount(); } log.debug(String.format("Open files: %d", getOpenFileDescriptorCount())); continue; } String msg = String.format("HSQLDB could not be started on %s:%d, state: %s", server.getAddress(), server.getPort(), server.getStateDescriptor()); if (t == null) { throw new IllegalStateException(msg); } else { throw new IllegalStateException(msg, t); } } while (true); log.info("Started HSQL Server"); }

Target:
public void afterPropertiesSet() throws Exception { HsqlProperties configProps = serverProperties != null ? new HsqlProperties(serverProperties) : new HsqlProperties(); ServerConfiguration.translateDefaultDatabaseProperty(configProps); server = new org.hsqldb.Server(); server.setLogWriter(null); server.setRestartOnShutdown(false); server.setNoSystemExit(true); server.setProperties(configProps); log.debug("HSQL Database path: " + server.getDatabasePath(0, true)); log.info("Starting HSQL Server database '" + server.getDatabaseName(0, true) + "' listening on port: " + server.getPort()); int tries = 0; boolean started; Throwable t = null; do { server.start(); started = server.getState() == ServerConstants.SERVER_STATE_ONLINE; if (!started) { Thread.sleep(1000); started = server.getState() == ServerConstants.SERVER_STATE_ONLINE; } if (!started) { t = server.getServerError(); if (t instanceof SocketException && "Invalid argument".equals(t.getMessage())) { long fileCount = getOpenFileDescriptorCount(); log.debug(String.format( "Caught SocketException (likely due to excessive file descriptors open; current count: %d)", fileCount), t); long timeout = System.currentTimeMillis() + 5000; while (System.currentTimeMillis() < timeout && fileCount > 1024) { Thread.sleep(500); fileCount = getOpenFileDescriptorCount(); } log.debug(String.format("Open files: %d", getOpenFileDescriptorCount())); } else { break; } } } while (!started && ++tries < 5); if (started) { log.info("Started HSQL Server"); } else { String msg = String.format("HSQLDB could not be started on %s:%d, state: %s", server.getAddress(), server.getPort(), server.getStateDescriptor()); if (t == null) { throw new IllegalStateException(msg); } else { throw new IllegalStateException(msg, t); } } }