Skip to content

Commit

Permalink
Merge pull request #378 from mattrjacobs/evaluate-pr-327-again
Browse files Browse the repository at this point in the history
Manual merge of #327
  • Loading branch information
mattrjacobs committed Dec 27, 2014
2 parents 737dac7 + 7d740d8 commit 376646b
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 13 deletions.
24 changes: 13 additions & 11 deletions hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ private Observable<R> getRunObservableDecoratedForMetricsAndErrorHandling(final

@Override
public void call(Subscriber<? super R> s) {
executionHook.onRunStart(_self);
executionHook.onThreadStart(_self);
executionHook.onRunStart(_self);
if (isCommandTimedOut.get() == TimedOutStatus.TIMED_OUT) {
// the command timed out in the wrapping thread so we will return immediately
// and not increment any of the counters below or other such logic
Expand Down Expand Up @@ -561,7 +561,6 @@ public void call(Notification<? super R> n) {

@Override
public R call(R t1) {
System.out.println("map " + t1);
if (!once) {
// report success
executionResult = executionResult.addEvents(HystrixEventType.SUCCESS);
Expand Down Expand Up @@ -617,6 +616,17 @@ public Observable<R> call(Throwable t) {
logger.warn("Error calling ExecutionHook.onRunError", hookException);
}

try {
Exception decorated = executionHook.onError(_self, FailureType.BAD_REQUEST_EXCEPTION, (Exception) t);

if (decorated instanceof HystrixBadRequestException) {
t = (HystrixBadRequestException) decorated;
} else {
logger.warn("ExecutionHook.onError returned an exception that was not an instance of HystrixBadRequestException so will be ignored.", decorated);
}
} catch (Exception hookException) {
logger.warn("Error calling ExecutionHook.onError", hookException);
}
/*
* HystrixBadRequestException is treated differently and allowed to propagate without any stats tracking or fallback logic
*/
Expand Down Expand Up @@ -750,15 +760,7 @@ private Observable<R> getFallbackOrThrowException(final HystrixEventType eventTy
executionResult = executionResult.addEvents(eventType);
final AbstractCommand<R> _cmd = this;

return getFallbackWithProtection().map(new Func1<R, R>() {

@Override
public R call(R t1) {
System.out.println(">>>>>>>>>>>> fallback on thread: " + Thread.currentThread());
return executionHook.onComplete(_cmd, t1);
}

}).doOnCompleted(new Action0() {
return getFallbackWithProtection().doOnCompleted(new Action0() {

@Override
public void call() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class HystrixRuntimeException extends RuntimeException {
private final FailureType failureCause;

public static enum FailureType {
COMMAND_EXCEPTION, TIMEOUT, SHORTCIRCUIT, REJECTED_THREAD_EXECUTION, REJECTED_SEMAPHORE_EXECUTION, REJECTED_SEMAPHORE_FALLBACK
BAD_REQUEST_EXCEPTION, COMMAND_EXCEPTION, TIMEOUT, SHORTCIRCUIT, REJECTED_THREAD_EXECUTION, REJECTED_SEMAPHORE_EXECUTION, REJECTED_SEMAPHORE_FALLBACK
}

public HystrixRuntimeException(FailureType failureCause, Class<? extends HystrixInvokable> commandClass, String message, Exception cause, Throwable fallbackException) {
Expand Down
Loading

0 comments on commit 376646b

Please sign in to comment.