From 002139912c6e49506a7466f4eff2b4098842df60 Mon Sep 17 00:00:00 2001 From: dmgcodevil Date: Wed, 21 Jun 2017 22:58:45 -0400 Subject: [PATCH] iss1600: Wrong hystrix event type for fallback missing --- .../javanica/command/AbstractHystrixCommand.java | 8 -------- .../fallback/BasicCommandFallbackTest.java | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/AbstractHystrixCommand.java b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/AbstractHystrixCommand.java index 784f8e3dc..661963534 100644 --- a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/AbstractHystrixCommand.java +++ b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/AbstractHystrixCommand.java @@ -167,14 +167,6 @@ Object process(Action action) throws Exception { @Override protected abstract T run() throws Exception; - /** - * {@inheritDoc}. - */ - @Override - protected T getFallback() { - throw new RuntimeException("No fallback available.", getExecutionException()); - } - /** * Clears cache for the specified hystrix command. */ diff --git a/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/fallback/BasicCommandFallbackTest.java b/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/fallback/BasicCommandFallbackTest.java index 4fd270882..fa73e94f1 100644 --- a/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/fallback/BasicCommandFallbackTest.java +++ b/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/fallback/BasicCommandFallbackTest.java @@ -218,8 +218,24 @@ public void testCommandThrowsHystrixBadRequestExceptionWithNoCause() { } } + @Test + public void testFallbackMissing(){ + try { + userService.getUserWithoutFallback(null, null); + } catch (Exception e) {} + + HystrixInvokableInfo command = getHystrixCommandByKey("getUserWithoutFallback"); + assertTrue("expected event: FALLBACK_MISSING", command.getExecutionEvents().contains(HystrixEventType.FALLBACK_MISSING)); + } + public static class UserService { + @HystrixCommand + public User getUserWithoutFallback(final String id, final String name) { + validate(id, name); + return new User(id, name); + } + @HystrixCommand(fallbackMethod = "fallback") public Future getUserAsync(final String id, final String name) { validate(id, name); // validate logic can be inside and outside of AsyncResult#invoke method