NIFI-4742: Clean up CaptureChangeMySQL connection resources on connect failure. This closes #2379

This commit is contained in:
Matthew Burgess 2018-01-05 15:08:20 -05:00 committed by Matt Gilman
parent 81d3f6f326
commit e43f07e31d
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
1 changed files with 3 additions and 0 deletions

View File

@ -704,6 +704,7 @@ public class CaptureChangeMySQL extends AbstractSessionFactoryProcessor {
}
}
if (!binlogClient.isConnected()) {
binlogClient.disconnect();
binlogClient = null;
throw new IOException("Could not connect binlog client to any of the specified hosts due to: " + lastConnectException.getMessage(), lastConnectException);
}
@ -712,6 +713,8 @@ public class CaptureChangeMySQL extends AbstractSessionFactoryProcessor {
try {
jdbcConnection = getJdbcConnection(driverLocation, driverName, connectedHost, username, password, null);
} catch (InitializationException | SQLException e) {
binlogClient.disconnect();
binlogClient = null;
throw new IOException("Error creating binlog enrichment JDBC connection to any of the specified hosts", e);
}
}