Skip to content

Commit ab82ecc

Browse files
authored
Merge pull request #233 from data-integrations/exc-handling
CDAP-20472: Fix missing logging for exceptions
2 parents ccd12fc + e82253b commit ab82ecc

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

delta-plugins-common/src/main/java/io/cdap/delta/plugin/common/DriverCleanup.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ public static DriverCleanup ensureJDBCDriverIsAvailable(Class<? extends Driver>
5656
DriverManager.getDriver(url);
5757
return new DriverCleanup(null);
5858
} catch (SQLException e) {
59+
LOG.warn("Error while getting JDBC Driver from URL {}", url, e);
5960
Driver driver = classz.newInstance();
6061
JDBCDriverShim shim = new JDBCDriverShim(driver);
6162
try {
6263
deregisterAllDrivers(classz);
6364
} catch (NoSuchFieldException | ClassNotFoundException e1) {
64-
LOG.warn("Unable to deregister JDBC Driver class {}", classz);
65+
LOG.warn("Unable to deregister JDBC Driver class {}", classz, e1);
6566
}
6667
DriverManager.registerDriver(shim);
6768
return new DriverCleanup(shim);

mysql-delta-plugins/src/main/java/io/cdap/delta/mysql/MySqlTableAssessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import io.cdap.delta.api.assessment.TableDetail;
2929
import io.cdap.delta.plugin.common.ColumnEvaluation;
3030
import io.cdap.delta.plugin.common.DriverCleanup;
31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
3133

3234
import java.io.IOException;
3335
import java.sql.Connection;
@@ -44,6 +46,7 @@
4446
* MySQL table assessor.
4547
*/
4648
public class MySqlTableAssessor implements TableAssessor<TableDetail> {
49+
private static final Logger LOG = LoggerFactory.getLogger(MySqlTableAssessor.class);
4750
static final String COLUMN_LENGTH = "COLUMN_LENGTH";
4851
static final String SCALE = "SCALE";
4952

@@ -197,6 +200,7 @@ private void checkReplicationPermissions(List<Problem> featureProblems, List<Str
197200
}
198201
}
199202
} catch (Exception e) {
203+
LOG.error("Error in checking permissions", e);
200204
featureProblems.add(permissionUnknownProblem);
201205
}
202206
}

sqlserver-delta-plugins/src/main/java/io/cdap/delta/sqlserver/SqlServerTableRegistry.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
* Sql Server table registry
5353
*/
5454
public class SqlServerTableRegistry implements TableRegistry {
55-
private static final Logger LOGGER = LoggerFactory.getLogger(SqlServerTableRegistry.class);
55+
private static final Logger LOG = LoggerFactory.getLogger(SqlServerTableRegistry.class);
5656
private final String jdbcUrl;
5757
private final SqlServerConfig config;
5858
private final DriverCleanup driverCleanup;
@@ -134,12 +134,12 @@ public TableDetail describeTable(String db, @Nullable String schema, String tabl
134134
}
135135
}
136136
} catch (Exception e) {
137+
String msg = String.format("Unable to check if CDC feature for table '%s' in database '%s' was enabled or not",
138+
schema == null ? table : schema + "." + table, db);
139+
LOG.error(msg, e);
137140
missingFeatures.add(
138-
new Problem("Unable To Check If CDC Was Enabled",
139-
String.format("Unable to check if CDC feature for table '%s' in database '%s' was enabled or not",
140-
schema == null ? table : schema + "." + table, db),
141-
"Check database connectivity and table information",
142-
null));
141+
new Problem("Unable To Check If CDC Was Enabled", msg,
142+
"Check database connectivity and table information", null));
143143
}
144144
return builder.setFeatures(missingFeatures).build();
145145
} catch (SQLException e) {
@@ -192,11 +192,11 @@ private Optional<TableDetail.Builder> getTableDetailBuilder(DatabaseMetaData dbM
192192
return Optional.empty();
193193
}
194194
List<String> primaryKey = new ArrayList<>();
195-
LOGGER.debug("Query primary key for {}.{}.{}", db, schema, table);
195+
LOG.debug("Query primary key for {}.{}.{}", db, schema, table);
196196
try (ResultSet keyResults = dbMeta.getPrimaryKeys(db, schema, table)) {
197197
while (keyResults.next()) {
198198
String pk = keyResults.getString("COLUMN_NAME");
199-
LOGGER.debug("Found primary key for {}.{}.{} : {}", db, schema, table, pk);
199+
LOG.debug("Found primary key for {}.{}.{} : {}", db, schema, table, pk);
200200
primaryKey.add(pk);
201201
}
202202
}

0 commit comments

Comments
 (0)