Skip to content

Commit 7e42011

Browse files
committed
satisfy checkstyle
1 parent f6f608e commit 7e42011

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed

src/main/java/com/github/shyiko/mysql/binlog/BinaryLogClient.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,9 @@ private void addGtidToSet(String gtid) {
989989

990990
private void updateGtidSet(Event event) {
991991
synchronized (gtidSetAccessLock) {
992-
if (gtidSet == null)
992+
if (gtidSet == null) {
993993
return;
994+
}
994995
}
995996

996997
EventHeader eventHeader = event.getHeader();
@@ -1008,7 +1009,7 @@ private void updateGtidSet(Event event) {
10081009
case QUERY:
10091010
QueryEventData qed = (QueryEventData) unwrapEventData(event.getData());
10101011
String sql = qed.getSql();
1011-
if ( sql == null ) {
1012+
if (sql == null) {
10121013
break;
10131014
}
10141015

@@ -1022,6 +1023,7 @@ private void updateGtidSet(Event event) {
10221023
//auto-commit query, likely DDL
10231024
addGtidToSet(currentGtid);
10241025
}
1026+
default:
10251027
}
10261028
}
10271029

src/test/java/com/github/shyiko/mysql/binlog/BinaryLogClientGTIDIntegrationTest.java

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
/*
2+
* Copyright 2013 Stanley Shyiko
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.github.shyiko.mysql.binlog;
217

3-
import com.github.shyiko.mysql.binlog.event.*;
18+
import com.github.shyiko.mysql.binlog.event.XidEventData;
19+
import com.github.shyiko.mysql.binlog.event.QueryEventData;
420
import com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer;
521
import org.testng.annotations.AfterClass;
622
import org.testng.annotations.BeforeClass;
@@ -15,6 +31,11 @@
1531
import static org.testng.Assert.assertNotEquals;
1632
import static org.testng.AssertJUnit.assertNotNull;
1733

34+
/**
35+
* MySQL replication stream client.
36+
*
37+
* @author <a href="mailto:stanley.shyiko@gmail.com">Stanley Shyiko</a>
38+
*/
1839
public class BinaryLogClientGTIDIntegrationTest extends BinaryLogClientIntegrationTest {
1940
private final Logger logger = Logger.getLogger(getClass().getSimpleName());
2041

@@ -27,7 +48,7 @@ private void enableGTID() throws SQLException {
2748
public void execute(Statement statement) throws SQLException {
2849
ResultSet rs = statement.executeQuery("select @@GLOBAL.GTID_MODE as gtid_mode");
2950
rs.next();
30-
if ( rs.getString("gtid_mode").equals("ON") ) {
51+
if ("ON".equals(rs.getString("gtid_mode"))) {
3152
return;
3253
}
3354

@@ -86,7 +107,6 @@ public void execute(ResultSet rs) throws SQLException {
86107
}
87108
});
88109

89-
90110
EventDeserializer eventDeserializer = new EventDeserializer();
91111
try {
92112
client.disconnect();

src/test/java/com/github/shyiko/mysql/binlog/BinaryLogClientIntegrationTest.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.github.shyiko.mysql.binlog.network.AuthenticationException;
3535
import com.github.shyiko.mysql.binlog.network.ServerException;
3636
import com.github.shyiko.mysql.binlog.network.SocketFactory;
37-
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
3837
import org.mockito.InOrder;
3938
import org.testng.SkipException;
4039
import org.testng.annotations.AfterClass;
@@ -727,20 +726,6 @@ public EventHeaderV4 deserialize(ByteArrayInputStream inputStream) throws IOExce
727726
}));
728727
}
729728

730-
protected class QueryEventFailureSimulator extends QueryEventDataDeserializer {
731-
private boolean failureSimulated;
732-
733-
@Override
734-
public QueryEventData deserialize(ByteArrayInputStream inputStream) throws IOException {
735-
QueryEventData eventData = super.deserialize(inputStream);
736-
if (!failureSimulated) {
737-
failureSimulated = true;
738-
throw new SocketException();
739-
}
740-
return eventData;
741-
}
742-
}
743-
744729
private void testCommunicationFailureInTheMiddleOfEventDataDeserialization(final IOException ex) throws Exception {
745730
EventDeserializer eventDeserializer = new EventDeserializer();
746731
eventDeserializer.setEventDataDeserializer(EventType.QUERY, new QueryEventFailureSimulator());
@@ -1103,8 +1088,9 @@ public void execute(Callback<Statement> callback, boolean autocommit) throws SQL
11031088
Statement statement = connection.createStatement();
11041089
try {
11051090
callback.execute(statement);
1106-
if ( !autocommit )
1091+
if (!autocommit) {
11071092
connection.commit();
1093+
}
11081094
} finally {
11091095
statement.close();
11101096
}
@@ -1166,4 +1152,22 @@ public interface Callback<T> {
11661152

11671153
void execute(T obj) throws SQLException;
11681154
}
1155+
1156+
/**
1157+
* @author <a href="mailto:stanley.shyiko@gmail.com">Stanley Shyiko</a>
1158+
*/
1159+
protected class QueryEventFailureSimulator extends QueryEventDataDeserializer {
1160+
private boolean failureSimulated;
1161+
1162+
@Override
1163+
public QueryEventData deserialize(ByteArrayInputStream inputStream) throws IOException {
1164+
QueryEventData eventData = super.deserialize(inputStream);
1165+
if (!failureSimulated) {
1166+
failureSimulated = true;
1167+
throw new SocketException();
1168+
}
1169+
return eventData;
1170+
}
1171+
}
1172+
11691173
}

0 commit comments

Comments
 (0)