protected void runTest() throws Throwable { final boolean stats = ((SessionFactoryImplementor) sessions).getStatistics().isStatisticsEnabled(); try { if (stats) sessions.getStatistics().clear(); super.runTest(); if (stats) sessions.getStatistics().logSummary(); if (session != null && session.isOpen()) { if (session.isConnected()) session.connection().rollback(); session.close(); session = null; fail("unclosed session"); } else { session = null; } } catch (Throwable e) { try { if (session != null && session.isOpen()) { if (session.isConnected()) session.connection().rollback(); session.close(); } } catch (Exception ignore) { } try { if (dropAfterFailure() && sessions != null) { sessions.close(); sessions = null; } } catch (Exception ignore) { } throw e; } }