Skip to content

Commit

Permalink
[misc] checktyle correction
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Aug 30, 2016
1 parent 9752c36 commit 4c5a143
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/mariadb/jdbc/BaseTest.java
Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down
22 changes: 8 additions & 14 deletions src/test/java/org/mariadb/jdbc/ErrorMessageTest.java
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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");
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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");
Expand Down

0 comments on commit 4c5a143

Please sign in to comment.