SimpleSQLChecker tighten up exception handling

This commit is contained in:
Travis Burtrum 2019-02-15 12:38:55 -05:00
parent 7b1b83fddd
commit 94d3ba89e0
2 changed files with 5 additions and 3 deletions

View File

@ -187,7 +187,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
(mapper.databaseType() == defaultDatabaseType ? defaultArrayStringTypeName : mapper.databaseType().arrayStringTypeName);
}
final ArrayInList arrayInList;
if(sqlChecker != null) {
if(sqlCheckerClass != null) {
switch(databaseType) {
case ORACLE:
arrayInList = new OracleArrayInList(arrayNumberTypeName, arrayStringTypeName);
@ -1230,6 +1230,8 @@ public class JdbcMapperProcessor extends AbstractProcessor {
}
public static String toString(final Throwable e) {
if (e == null)
return "exception object was null";
StringWriter sw = null;
PrintWriter pw = null;
try {

View File

@ -83,9 +83,9 @@ public class SimpleSQLChecker implements SQLChecker {
}
public void handleException(final Messager messager, final Exception e, final TypeElement classElement, final ExecutableElement method) {
if (e.getMessage().startsWith("ORA-02291: integrity constraint"))
if (e != null && e.getMessage() != null && e.getMessage().startsWith("ORA-02291: integrity constraint"))
return; // since we make up values and rollback we can ignore this, it means SQL is correct at least
getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage(), method);
messager.printMessage(Diagnostic.Kind.ERROR, e == null || e.getMessage() == null ? JdbcMapperProcessor.toString(e) : e.getMessage(), method);
}
public Collection<Object> getFakeBindParams(final List<VariableElement> bindParams, final Connection conn, final ArrayInList arrayInList) throws SQLException {