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 @@ -495,8 +495,9 @@ public void setThreadFactory(ThreadFactory threadFactory) {
* @throws AuthenticationException if authentication fails
* @throws ServerException if MySQL server responds with an error
* @throws IOException if anything goes wrong while trying to connect
* @throws IllegalStateException if binary log client is already connected
*/
public void connect() throws IOException {
public void connect() throws IOException, IllegalStateException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
Expand Down Expand Up @@ -836,8 +837,8 @@ public void run() {
try {
setConnectTimeout(timeout);
connect();
} catch (IOException e) {
exceptionReference.set(e);
} catch (Exception e) {
exceptionReference.set(new IOException(e)); // method is asynchronous, catch all exceptions so that they are not lost
countDownLatch.countDown(); // making sure we don't end up waiting whole "timeout"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,12 @@ public void testExceptionIsThrownWhenTryingToConnectAlreadyConnectedClient() thr
client.connect();
}

@Test(expectedExceptions = IOException.class)
public void testExceptionIsThrownWhenTryingToConnectAlreadyConnectedClientWithTimeout() throws Exception {
assertTrue(client.isConnected());
client.connect(1000);
}

@Test
public void testExceptionIsThrownWhenProvidedWithWrongCredentials() throws Exception {
BinaryLogClient binaryLogClient =
Expand Down