MySQLQueryInterceptor implements QueryInterceptor { @Override public <T extends Resultset> T postProcess(Supplier<String> sql, Query interceptedQuery, T originalResultSet, ServerSession serverSession) { boolean noIndexUsed = serverSession.noIndexUsed(); boolean badIndexUsed = serverSession.noGoodIndexUsed(); if (noIndexUsed || badIndexUsed) { boolean suppress = suppressSlowSQLWarning(); String message = noIndexUsed ? "no index used" : "bad index used"; String sqlValue = sql.get(); if (suppress) { LOGGER.debug("{}, sql={}", message, sqlValue); } else { LOGGER.warn(errorCode("SLOW_SQL"), "{}, sql={}", message, sqlValue); } } return null; }  @Override QueryInterceptor init(MysqlConnection connection, Properties properties, Log log); @Override T preProcess(Supplier<String> sql, Query interceptedQuery); @Override boolean executeTopLevelOnly(); @Override void destroy(); @Override T postProcess(Supplier<String> sql, Query interceptedQuery, T originalResultSet, ServerSession serverSession);  }
@Test void postProcess() { when(session.noGoodIndexUsed()).thenReturn(Boolean.TRUE); Database.suppressSlowSQLWarning(true); interceptor.postProcess(() -> "sql", null, null, session); Database.suppressSlowSQLWarning(false); assertThat(actionLog.errorCode()).isNull(); interceptor.postProcess(() -> "sql", null, null, session); assertThat(actionLog.errorCode()).isEqualTo("SLOW_SQL"); }