Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void switchConnectionIfRequired(final boolean readOnly) throws SQLException {
} catch (final SQLException e) {
if (!isConnectionUsable(currentConnection)) {
logAndThrowException(Messages.get("ReadWriteSplittingPlugin.errorSwitchingToReader"),
SqlState.CONNECTION_UNABLE_TO_CONNECT);
SqlState.CONNECTION_UNABLE_TO_CONNECT, e);
return;
}

Expand All @@ -318,7 +318,7 @@ void switchConnectionIfRequired(final boolean readOnly) throws SQLException {
switchToWriterConnection(hosts);
} catch (final SQLException e) {
logAndThrowException(Messages.get("ReadWriteSplittingPlugin.errorSwitchingToWriter"),
SqlState.CONNECTION_UNABLE_TO_CONNECT);
SqlState.CONNECTION_UNABLE_TO_CONNECT, e);
}
}
}
Expand All @@ -335,6 +335,13 @@ private void logAndThrowException(final String logMessage, final SqlState sqlSta
throw new ReadWriteSplittingSQLException(logMessage, sqlState.getState());
}

private void logAndThrowException(
final String logMessage, final SqlState sqlState, final Throwable cause)
throws SQLException {
LOGGER.severe(logMessage);
throw new ReadWriteSplittingSQLException(logMessage, sqlState.getState(), cause);
}

private synchronized void switchToWriterConnection(
final List<HostSpec> hosts)
throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.TestTemplate;
Expand Down