From dee82b92a77e3d4d3f3f9c1bc3e6ea65c71f1256 Mon Sep 17 00:00:00 2001 From: Matthew Burgess Date: Fri, 5 Jan 2018 15:08:20 -0500 Subject: [PATCH] NIFI-4742: Clean up CaptureChangeMySQL connection resources on connect failure --- .../apache/nifi/cdc/mysql/processors/CaptureChangeMySQL.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nifi-nar-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/main/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQL.java b/nifi-nar-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/main/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQL.java index 5ee51fd27dc8..d15ad6bcde2e 100644 --- a/nifi-nar-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/main/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQL.java +++ b/nifi-nar-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/main/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQL.java @@ -704,6 +704,7 @@ protected void connect(List hosts, String username, String pa } } 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 @@ protected void connect(List hosts, String username, String pa 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); } }