Skip to content

Commit

Permalink
Merge pull request #876 from mattrjacobs/fix-racy-request-log
Browse files Browse the repository at this point in the history
Fixed #847 by adding BAD_REQUEST to the HystrixRequestLog
  • Loading branch information
mattrjacobs committed Aug 25, 2015
2 parents a98f3de + 81cdd45 commit 0e92136
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ public Observable<R> call(Throwable t) {
*/
try {
metrics.markBadRequest(System.currentTimeMillis() - invocationStartTime);
executionResult = executionResult.addEvents(HystrixEventType.BAD_REQUEST);
Exception decorated = executionHook.onError(_self, FailureType.BAD_REQUEST_EXCEPTION, (Exception) t);

if (decorated instanceof HystrixBadRequestException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ public void onNext(Object t) {
}
}

protected void assertSaneHystrixRequestLog(final int numCommands) {
HystrixRequestLog currentRequestLog = HystrixRequestLog.getCurrentRequest();

try {
assertEquals(numCommands, currentRequestLog.getAllExecutedCommands().size());
assertFalse(currentRequestLog.getExecutedCommandsAsString().contains("Executed"));
assertTrue(currentRequestLog.getAllExecutedCommands().iterator().next().getExecutionEvents().size() >= 1);
//Most commands should have 1 execution event, but fallbacks / responses from cache can cause more than 1. They should never have 0
} catch (Throwable ex) {
System.out.println("Problematic Request log : " + currentRequestLog.getExecutedCommandsAsString() + " , expected : " + numCommands);
throw new RuntimeException(ex);
}
}

/**
* Threadpool with 1 thread, queue of size 1
*/
Expand Down
Loading

0 comments on commit 0e92136

Please sign in to comment.