recordAlreadyExists is silently eaten with no warning to logs
GENERAL
TESTING
GENERAL
TESTING
Description
This code in BasicSqlService.java effectively means that SqlServiceUniqueViolationException will never be thrown (as the if (recordAlreadyExists) block is unreachable).
As nothing seems to actually catch SqlServiceUniqueViolationException, that block should just be removed.
1223 // if asked to fail quietly, just return false if we find this error. 1224 if (recordAlreadyExists || failQuiet) return false; 1225 1226 // perhaps due to a mysql deadlock? 1227 if (sqlServiceSql.isDeadLockError(e.getErrorCode())) 1228 { 1229 // just a little fuss 1230 LOG.warn("Sql.dbWrite(): deadlock: error code: " + e.getErrorCode() + " sql: " + sql + " binds: " + debugFields(fields) + " " + e.toString()); 1231 throw new SqlServiceDeadlockException(e); 1232 } 1233 1234 else if (recordAlreadyExists) 1235 { 1236 // just a little fuss 1237 LOG.warn("Sql.dbWrite(): unique violation: error code: " + e.getErrorCode() + " sql: " + sql + " binds: " + debugFields(fields) + " " + e.toString()); 1238 throw new SqlServiceUniqueViolationException(e); 1239 }
This code in BasicSqlService.java effectively means that SqlServiceUniqueViolationException will never be thrown (as the if (recordAlreadyExists) block is unreachable).
As nothing seems to actually catch SqlServiceUniqueViolationException, that block should just be removed.
1223 // if asked to fail quietly, just return false if we find this error.
1224 if (recordAlreadyExists || failQuiet) return false;
1225
1226 // perhaps due to a mysql deadlock?
1227 if (sqlServiceSql.isDeadLockError(e.getErrorCode()))
1228 {
1229 // just a little fuss
1230 LOG.warn("Sql.dbWrite(): deadlock: error code: " + e.getErrorCode() + " sql: " + sql + " binds: " + debugFields(fields) + " " + e.toString());
1231 throw new SqlServiceDeadlockException(e);
1232 }
1233
1234 else if (recordAlreadyExists)
1235 {
1236 // just a little fuss
1237 LOG.warn("Sql.dbWrite(): unique violation: error code: " + e.getErrorCode() + " sql: " + sql + " binds: " + debugFields(fields) + " " + e.toString());
1238 throw new SqlServiceUniqueViolationException(e);
1239 }