Skip to content

Commit

Permalink
Correct exception logging (#1882)
Browse files Browse the repository at this point in the history
* Correct exception logging

* re-interrupt thread

Co-authored-by: Aaron Klish <aklish@gmail.com>
  • Loading branch information
wcekan and aklish committed Mar 10, 2021
1 parent 6c97725 commit 36fb163
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
Expand Up @@ -40,10 +40,11 @@ public void run() {
asyncAPIDao.updateAsyncAPIResult(queryResultObj, queryObj.getId(), queryObj.getClass());

} catch (InterruptedException e) {
log.error("InterruptedException: {}", e);
Thread.currentThread().interrupt();
log.error("InterruptedException: {}", e.toString());
asyncAPIDao.updateStatus(queryObj.getId(), QueryStatus.FAILURE, queryObj.getClass());
} catch (Exception e) {
log.error("Exception: {}", e);
log.error("Exception: {}", e.toString());
asyncAPIDao.updateStatus(queryObj.getId(), QueryStatus.FAILURE, queryObj.getClass());
}
}
Expand Down
Expand Up @@ -87,16 +87,17 @@ public void executeQuery(AsyncAPI queryObj, Callable<AsyncAPIResult> callable) {
queryObj.setStatus(QueryStatus.COMPLETE);
queryObj.setUpdatedOn(new Date());
} catch (InterruptedException e) {
log.error("InterruptedException: {}", e);
Thread.currentThread().interrupt();
log.error("InterruptedException: {}", e.toString());
queryObj.setStatus(QueryStatus.FAILURE);
} catch (ExecutionException e) {
log.error("ExecutionException: {}", e);
log.error("ExecutionException: {}", e.toString());
queryObj.setStatus(QueryStatus.FAILURE);
} catch (TimeoutException e) {
log.error("TimeoutException: {}", e);
log.error("TimeoutException: {}", e.toString());
resultFuture.setSynchronousTimeout(true);
} catch (Exception e) {
log.error("Exception: {}", e);
log.error("Exception: {}", e.toString());
queryObj.setStatus(QueryStatus.FAILURE);
} finally {
asyncResultFutureThreadLocal.set(resultFuture);
Expand Down
Expand Up @@ -170,7 +170,7 @@ protected Object executeInTransaction(DataStore dataStore, Transactional action)
tx.flush(scope);
tx.commit(scope);
} catch (IOException e) {
log.error("IOException: {}", e);
log.error("IOException: {}", e.toString());
throw new IllegalStateException(e);
}
return result;
Expand All @@ -193,7 +193,7 @@ public <T extends AsyncAPI> Iterable<T> loadAsyncAPIByFilter(FilterExpression fi
return loaded;
});
} catch (Exception e) {
log.error("Exception: {}", e);
log.error("Exception: {}", e.toString());
throw new IllegalStateException(e);
}
return asyncAPIList;
Expand Down
Expand Up @@ -119,7 +119,7 @@ protected <T extends AsyncAPI> void cancelAsyncAPI(Class<T> type) {
type);
}
} catch (Exception e) {
log.error("Exception in scheduled cancellation: {}", e);
log.error("Exception in scheduled cancellation: {}", e.toString());
}
}
}
Expand Up @@ -58,7 +58,7 @@ protected <T extends AsyncAPI> void deleteAsyncAPI(Class<T> type) {
FilterExpression fltDeleteExp = new LEPredicate(createdOnPathElement, cleanupDate);
asyncAPIDao.deleteAsyncAPIAndResultByFilter(fltDeleteExp, type);
} catch (Exception e) {
log.error("Exception in scheduled cleanup: {}", e);
log.error("Exception in scheduled cleanup: {}", e.toString());
}
}

Expand All @@ -79,7 +79,7 @@ protected <T extends AsyncAPI> void timeoutAsyncAPI(Class<T> type) {
AndFilterExpression fltTimeoutExp = new AndFilterExpression(inPredicate, lePredicate);
asyncAPIDao.updateStatusAsyncAPIByFilter(fltTimeoutExp, QueryStatus.TIMEDOUT, type);
} catch (Exception e) {
log.error("Exception in scheduled cleanup: {}", e);
log.error("Exception in scheduled cleanup: {}", e.toString());
}
}
}
Expand Up @@ -115,7 +115,7 @@ private ParseTree getPermissionExpressionTree(Class<? extends Annotation> annota

return parseExpression(expression);
} catch (ReflectiveOperationException e) {
log.warn("Unknown permission: {}, {}", annotationClass.getName(), e);
log.warn("Unknown permission: {}, {}", annotationClass.getName(), e.toString());
throw new IllegalArgumentException("Unknown permission '" + annotationClass.getName() + "'", e);
}
}
Expand Down
Expand Up @@ -35,6 +35,7 @@ public Iterable<Object> loadObjects(EntityProjection entityProjection, RequestSc
Thread.sleep(Integer.parseInt(sleepTime.get(0)));
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.debug("Test delay interrupted");
}
return super.loadObjects(entityProjection, scope);
Expand Down

0 comments on commit 36fb163

Please sign in to comment.