From 4c5a1432fe1db2a95543650ad2148a0a41aea943 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Wed, 31 Aug 2016 00:29:01 +0200 Subject: [PATCH] [misc] checktyle correction --- .../failover/AbstractMastersListener.java | 8 +++---- src/test/java/org/mariadb/jdbc/BaseTest.java | 14 ++++++------ .../org/mariadb/jdbc/ErrorMessageTest.java | 22 +++++++------------ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java b/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java index 04da72259..3fa84ecd0 100644 --- a/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java +++ b/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java @@ -279,8 +279,8 @@ public HandleErrorResult relaunchOperation(Method method, Object[] args) throws String query = ((String) args[2]).toUpperCase(); if (!query.equals("ALTER SYSTEM CRASH") && !query.startsWith("KILL")) { - logger.debug("relaunch query to new connection " + - ((currentProtocol != null) ? "server thread id " + currentProtocol.getServerThreadId() : "")); + logger.debug("relaunch query to new connection " + + ((currentProtocol != null) ? "server thread id " + currentProtocol.getServerThreadId() : "")); handleErrorResult.resultObject = method.invoke(currentProtocol, args); handleErrorResult.mustThrowError = false; } @@ -294,8 +294,8 @@ public HandleErrorResult relaunchOperation(Method method, Object[] args) throws ServerPrepareResult oldServerPrepareResult = (ServerPrepareResult) args[1]; ServerPrepareResult serverPrepareResult = currentProtocol.prepare(oldServerPrepareResult.getSql(), mustBeOnMaster); oldServerPrepareResult.failover(serverPrepareResult.getStatementId(), currentProtocol); - logger.debug("relaunch query to new connection " + - ((currentProtocol != null) ? "server thread id " + currentProtocol.getServerThreadId() : "")); + logger.debug("relaunch query to new connection " + + ((currentProtocol != null) ? "server thread id " + currentProtocol.getServerThreadId() : "")); handleErrorResult.resultObject = method.invoke(currentProtocol, args); handleErrorResult.mustThrowError = false; } catch (Exception e) { diff --git a/src/test/java/org/mariadb/jdbc/BaseTest.java b/src/test/java/org/mariadb/jdbc/BaseTest.java index ec59cc432..6f06c2485 100644 --- a/src/test/java/org/mariadb/jdbc/BaseTest.java +++ b/src/test/java/org/mariadb/jdbc/BaseTest.java @@ -366,6 +366,13 @@ protected void setPassword(String password) throws SQLException { setConnection(); } + protected Connection setBlankConnection(String parameters) throws SQLException { + return openConnection(connU + + "?user=" + username + + (password != null && !"".equals(password) ? "&password=" + password : "") + + parameters, null); + } + protected Connection setConnection() throws SQLException { return openConnection(connUri, null); } @@ -386,13 +393,6 @@ protected Connection setConnection(String parameters) throws SQLException { return openConnection(connUri + parameters, null); } - protected Connection setBlankConnection(String parameters) throws SQLException { - return openConnection(connU - + "?user=" + username - + (password != null && !"".equals(password) ? "&password=" + password : "") - + parameters, null); - } - protected Connection setConnection(String additionnallParameters, String database) throws SQLException { String connU = "jdbc:mysql://" + ((hostname == null) ? "localhost" : hostname) + ":" + port + "/" + database; diff --git a/src/test/java/org/mariadb/jdbc/ErrorMessageTest.java b/src/test/java/org/mariadb/jdbc/ErrorMessageTest.java index 8558270ac..c289026cd 100644 --- a/src/test/java/org/mariadb/jdbc/ErrorMessageTest.java +++ b/src/test/java/org/mariadb/jdbc/ErrorMessageTest.java @@ -24,7 +24,7 @@ public static void initClass() throws SQLException { @Test public void testSmallRewriteErrorMessage() throws SQLException { - try (Connection connection = setConnection("&rewriteBatchedStatements=true")) { + try (Connection connection = setBlankConnection("&rewriteBatchedStatements=true")) { executeBatchWithException(connection); fail("Must Have thrown error"); } catch (SQLException sqle) { @@ -36,8 +36,7 @@ public void testSmallRewriteErrorMessage() throws SQLException { @Test public void testSmallMultiBatchErrorMessage() throws SQLException { - Assume.assumeFalse(sharedIsRewrite()); - try (Connection connection = setConnection("&allowMultiQueries=true&useServerPrepStmts=false")) { + try (Connection connection = setBlankConnection("&allowMultiQueries=true&useServerPrepStmts=false")) { executeBatchWithException(connection); fail("Must Have thrown error"); } catch (SQLException sqle) { @@ -48,8 +47,7 @@ public void testSmallMultiBatchErrorMessage() throws SQLException { @Test public void testSmallPrepareErrorMessage() throws SQLException { - Assume.assumeTrue(sharedUsePrepare()); - try (Connection connection = setConnection("&useBatchMultiSend=false")) { + try (Connection connection = setBlankConnection("&useBatchMultiSend=false")) { executeBatchWithException(connection); fail("Must Have thrown error"); } catch (SQLException sqle) { @@ -60,8 +58,7 @@ public void testSmallPrepareErrorMessage() throws SQLException { @Test public void testSmallBulkErrorMessage() throws SQLException { - Assume.assumeTrue(sharedUsePrepare()); - Connection connection = setConnection("&useBatchMultiSend=true"); + Connection connection = setBlankConnection("&useBatchMultiSend=true"); try { executeBatchWithException(connection); fail("Must Have thrown error"); @@ -76,7 +73,7 @@ public void testSmallBulkErrorMessage() throws SQLException { @Test public void testBigRewriteErrorMessage() throws SQLException { - try (Connection connection = setConnection("&rewriteBatchedStatements=true")) { + try (Connection connection = setBlankConnection("&rewriteBatchedStatements=true")) { executeBigBatchWithException(connection); fail("Must Have thrown error"); } catch (SQLException sqle) { @@ -86,8 +83,7 @@ public void testBigRewriteErrorMessage() throws SQLException { @Test public void testBigMultiErrorMessage() throws SQLException { - Assume.assumeFalse(sharedIsRewrite()); - try (Connection connection = setConnection("&allowMultiQueries=true&useServerPrepStmts=false")) { + try (Connection connection = setBlankConnection("&allowMultiQueries=true&useServerPrepStmts=false")) { executeBigBatchWithException(connection); fail("Must Have thrown error"); } catch (SQLException sqle) { @@ -98,8 +94,7 @@ public void testBigMultiErrorMessage() throws SQLException { @Test public void testBigPrepareErrorMessage() throws SQLException { - Assume.assumeTrue(sharedUsePrepare()); - try (Connection connection = setConnection("&useBatchMultiSend=false")) { + try (Connection connection = setBlankConnection("&useBatchMultiSend=false")) { executeBigBatchWithException(connection); fail("Must Have thrown error"); } catch (SQLException sqle) { @@ -110,8 +105,7 @@ public void testBigPrepareErrorMessage() throws SQLException { @Test public void testBigBulkErrorMessage() throws SQLException { - Assume.assumeTrue(sharedUsePrepare()); - Connection connection = setConnection("&useBatchMultiSend=true"); + Connection connection = setBlankConnection("&useBatchMultiSend=true"); try { executeBigBatchWithException(connection); fail("Must Have thrown error");