diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java b/hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java index 573da2a28..823e66a35 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java @@ -16,7 +16,6 @@ package com.netflix.hystrix; import java.lang.ref.Reference; -import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -70,7 +69,7 @@ protected static enum TimedOutStatus { NOT_EXECUTED, COMPLETED, TIMED_OUT - }; + } protected final HystrixCommandMetrics metrics; @@ -480,7 +479,7 @@ public void call() { o = new CachedObservableResponse<>((CachedObservableOriginal) fromCache, this); } // we just created an ObservableCommand so we cast and return it - return (ObservableCommand) o; + return o; } else { // no request caching so a simple wrapper just to pass 'this' along with the Observable return new ObservableCommand<>(o, this); @@ -499,7 +498,7 @@ private Observable getRunObservableDecoratedForMetricsAndErrorHandling() { final HystrixRequestContext currentRequestContext = HystrixRequestContext.getContextForCurrentThread(); - Observable run = null; + Observable run; if (properties.executionIsolationStrategy().get().equals(ExecutionIsolationStrategy.THREAD)) { // mark that we are executing in a thread (even if we end up being rejected we still were a THREAD execution and not SEMAPHORE) @@ -605,7 +604,7 @@ public Observable call(Throwable t) { Exception decorated = executionHook.onError(_self, FailureType.BAD_REQUEST_EXCEPTION, (Exception) t); if (decorated instanceof HystrixBadRequestException) { - t = (HystrixBadRequestException) decorated; + t = decorated; } else { logger.warn("ExecutionHook.onError returned an exception that was not an instance of HystrixBadRequestException so will be ignored.", decorated); } @@ -721,7 +720,7 @@ private Observable getFallbackWithProtection() { executionHook.onFallbackStart(this); final AbstractCommand _cmd = this; - Observable fallback = null; + Observable fallback; try { fallback = getFallbackObservable(); } catch (Throwable t) { @@ -745,7 +744,7 @@ public Observable call(Throwable t) { Exception decorated = executionHook.onFallbackError(_cmd, e); if (decorated instanceof RuntimeException) { - e = (RuntimeException) decorated; + e = decorated; } else { logger.warn("ExecutionHook.onFallbackError returned an exception that was not an instance of RuntimeException so will be ignored.", decorated); } @@ -1432,7 +1431,7 @@ private ExecutionResult(List events, int executionTime, Except } // we can return a static version since it's immutable - private static ExecutionResult EMPTY = new ExecutionResult(new HystrixEventType[0]); + private static ExecutionResult EMPTY = new ExecutionResult(); /** * Creates a new ExecutionResult by adding the defined 'events' to the ones on the current instance. @@ -1443,9 +1442,7 @@ private ExecutionResult(List events, int executionTime, Except public ExecutionResult addEvents(HystrixEventType... events) { ArrayList newEvents = new ArrayList<>(); newEvents.addAll(this.events); - for (HystrixEventType e : events) { - newEvents.add(e); - } + Collections.addAll(newEvents, events); return new ExecutionResult(Collections.unmodifiableList(newEvents), executionTime, exception); } @@ -1633,7 +1630,7 @@ public long getCommandRunStartTimeInNanos() { } protected Exception getExceptionFromThrowable(Throwable t) { - Exception e = null; + Exception e; if (t instanceof Exception) { e = (Exception) t; } else { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/Hystrix.java b/hystrix-core/src/main/java/com/netflix/hystrix/Hystrix.java index 645d20439..3d5d8570a 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/Hystrix.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/Hystrix.java @@ -5,7 +5,6 @@ import java.util.concurrent.TimeUnit; import com.netflix.hystrix.strategy.HystrixPlugins; -import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherFactory; import com.netflix.hystrix.strategy.properties.HystrixPropertiesFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapser.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapser.java index 98f065128..42e4a2f93 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapser.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapser.java @@ -20,7 +20,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; -import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherCollapser; import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherFactory; import com.netflix.hystrix.strategy.properties.HystrixPropertiesFactory; import org.slf4j.Logger; @@ -379,7 +378,7 @@ public Observable toObservable() { public Observable toObservable(Scheduler observeOn) { /* try from cache first */ - if (getProperties().requestCachingEnabled().get()) { + if (getProperties().requestCacheEnabled().get()) { Observable fromCache = requestCache.get(getCacheKey()); if (fromCache != null) { metrics.markResponseFromCache(); @@ -390,7 +389,7 @@ public Observable toObservable(Scheduler observeOn) { RequestCollapser requestCollapser = collapserFactory.getRequestCollapser(collapserInstanceWrapper); Observable response = requestCollapser.submitRequest(getRequestArgument()); metrics.markRequestBatched(); - if (getProperties().requestCachingEnabled().get()) { + if (getProperties().requestCacheEnabled().get()) { /* * A race can occur here with multiple threads queuing but only one will be cached. * This means we can have some duplication of requests in a thread-race but we're okay diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserProperties.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserProperties.java index df47ac569..d2deb243a 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserProperties.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserProperties.java @@ -350,7 +350,7 @@ public HystrixProperty timerDelayInMilliseconds() { } private static enum TestHystrixCollapserKey implements HystrixCollapserKey { - TEST; + TEST } } diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java index 6da326c93..a82c445fc 100755 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java @@ -15,11 +15,8 @@ */ package com.netflix.hystrix; -import java.lang.ref.Reference; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import rx.Observable; import rx.Observable.OnSubscribe; @@ -30,7 +27,6 @@ import com.netflix.hystrix.exception.HystrixRuntimeException.FailureType; import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; -import com.netflix.hystrix.util.HystrixTimer.TimerListener; /** * Used to wrap code that will execute potentially risky functionality (typically meaning a service call over the network) diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCollapser.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCollapser.java index 77f992988..d4742a0d6 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCollapser.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCollapser.java @@ -370,7 +370,7 @@ public Observable toObservable() { public Observable toObservable(Scheduler observeOn) { /* try from cache first */ - if (getProperties().requestCachingEnabled().get()) { + if (getProperties().requestCacheEnabled().get()) { Observable fromCache = requestCache.get(getCacheKey()); if (fromCache != null) { /* mark that we received this response from cache */ @@ -384,7 +384,7 @@ public Observable toObservable(Scheduler observeOn) { RequestCollapser requestCollapser = collapserFactory.getRequestCollapser(collapserInstanceWrapper); Observable response = requestCollapser.submitRequest(getRequestArgument()); - if (getProperties().requestCachingEnabled().get()) { + if (getProperties().requestCacheEnabled().get()) { /* * A race can occur here with multiple threads queuing but only one will be cached. * This means we can have some duplication of requests in a thread-race but we're okay diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCommand.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCommand.java index 4b1ff4d76..141ab7df7 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCommand.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCommand.java @@ -16,12 +16,8 @@ package com.netflix.hystrix; import rx.Observable; -import rx.functions.Func1; -import rx.schedulers.Schedulers; import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy; -import com.netflix.hystrix.exception.HystrixBadRequestException; -import com.netflix.hystrix.exception.HystrixRuntimeException; import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestCache.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestCache.java index dd0b13d59..2ba961b9f 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestCache.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestCache.java @@ -57,7 +57,7 @@ public ConcurrentHashMap> initialValue() { @Override public void shutdown(ConcurrentHashMap> value) { // nothing to shutdown - }; + } }); diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestLog.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestLog.java index 6b77b33a9..24c56a35b 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestLog.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestLog.java @@ -58,7 +58,7 @@ public HystrixRequestLog initialValue() { public void shutdown(HystrixRequestLog value) { // nothing to shutdown - }; + } }); diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolProperties.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolProperties.java index 3c02f10a7..c596cac13 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolProperties.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolProperties.java @@ -290,7 +290,7 @@ public HystrixProperty metricsRollingStatisticalWindowBuckets() { } private static enum TestThreadPoolKey implements HystrixThreadPoolKey { - TEST; + TEST } } } diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java index 04fdc0dc7..d3c693327 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java @@ -115,7 +115,7 @@ public void executeBatchIfNotAlreadyStarted() { @Override public void call(Throwable e) { // handle Throwable in case anything is thrown so we don't block Observers waiting for onError/onCompleted - Exception ee = null; + Exception ee; if (e instanceof Exception) { ee = (Exception) e; } else { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapserFactory.java b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapserFactory.java index c782146f0..76897e968 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapserFactory.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapserFactory.java @@ -2,8 +2,6 @@ import java.util.concurrent.ConcurrentHashMap; -import com.netflix.hystrix.HystrixCollapserMetrics; -import com.netflix.hystrix.HystrixCommandMetrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixConcurrencyStrategy.java b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixConcurrencyStrategy.java index a7d81a758..406d5f1a0 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixConcurrencyStrategy.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixConcurrencyStrategy.java @@ -147,7 +147,7 @@ public T initialValue() { public void shutdown(T value) { rv.shutdown(value); - }; + } }; } diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestContext.java b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestContext.java index 2e52e9bed..10f4a4477 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestContext.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestContext.java @@ -141,5 +141,5 @@ public void shutdown() { // being held in ThreadLocals on threads that weren't cleaned up state = null; } - }; + } } \ No newline at end of file diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCircuitBreakerTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCircuitBreakerTest.java index 64ff4610d..f3b5e93b9 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCircuitBreakerTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCircuitBreakerTest.java @@ -490,15 +490,15 @@ private static HystrixCircuitBreaker getCircuitBreaker(HystrixCommandKey key, Hy } private static enum CommandOwnerForUnitTest implements HystrixCommandGroupKey { - OWNER_ONE, OWNER_TWO; + OWNER_ONE, OWNER_TWO } private static enum ThreadPoolKeyForUnitTest implements HystrixThreadPoolKey { - THREAD_POOL_ONE, THREAD_POOL_TWO; + THREAD_POOL_ONE, THREAD_POOL_TWO } private static enum CommandKeyForUnitTest implements HystrixCommandKey { - KEY_ONE, KEY_TWO; + KEY_ONE, KEY_TWO } // ignoring since this never ends ... useful for testing https://github.com/Netflix/Hystrix/issues/236 diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCollapserTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCollapserTest.java index a14f5de59..79b4aa40f 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCollapserTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCollapserTest.java @@ -866,7 +866,7 @@ public void testVoidResponseTypeFireAndForgetCollapsing2() throws Exception { TestCollapserTimer timer = new TestCollapserTimer(); TestCollapserWithVoidResponseTypeAndMissingMapResponseToRequests collapser1 = new TestCollapserWithVoidResponseTypeAndMissingMapResponseToRequests(timer, 1); Future response1 = collapser1.queue(); - Future response2 = new TestCollapserWithVoidResponseTypeAndMissingMapResponseToRequests(timer, 2).queue(); + new TestCollapserWithVoidResponseTypeAndMissingMapResponseToRequests(timer, 2).queue(); timer.incrementTime(100); // let time pass that equals the default delay/period // we will fetch one of these just so we wait for completion ... but expect an error @@ -944,8 +944,7 @@ public TestRequestCollapser(TestCollapserTimer timer, String value, int defaultM private static HystrixCollapserMetrics createMetrics() { HystrixCollapserKey key = HystrixCollapserKey.Factory.asKey("COLLAPSER_ONE"); - HystrixCollapserMetrics metrics = HystrixCollapserMetrics.getInstance(key, new HystrixPropertiesCollapserDefault(key, HystrixCollapserProperties.Setter())); - return metrics; + return HystrixCollapserMetrics.getInstance(key, new HystrixPropertiesCollapserDefault(key, HystrixCollapserProperties.Setter())); } public TestRequestCollapser(Scope scope, TestCollapserTimer timer, String value, int defaultMaxRequestsInBatch, int defaultTimerDelayInMilliseconds, ConcurrentLinkedQueue>> executionLog) { @@ -1096,7 +1095,7 @@ protected List run() { if (request.getArgument() == null) { throw new NullPointerException("Simulated Error"); } - if (request.getArgument() == "TIMEOUT") { + if (request.getArgument().equals("TIMEOUT")) { try { Thread.sleep(200); } catch (InterruptedException e) { diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandPropertiesTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandPropertiesTest.java index 019e21ca4..a3e90bbd9 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandPropertiesTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandPropertiesTest.java @@ -166,7 +166,7 @@ public HystrixProperty requestLogEnabled() { // NOTE: We use "unitTestPrefix" as a prefix so we can't end up pulling in external properties that change unit test behavior public enum TestKey implements HystrixCommandKey { - TEST; + TEST } private static class TestPropertiesCommand extends HystrixCommandProperties { diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java index 5b021c7f6..dd4cdcbe8 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java @@ -3149,10 +3149,10 @@ public void testCacheKeyExecutionRequiresRequestVariable() { TestCircuitBreaker circuitBreaker = new TestCircuitBreaker(); SuccessfulCacheableCommand command = new SuccessfulCacheableCommand(circuitBreaker, true, "one"); - assertEquals(true, command.execute()); + assertEquals("one", command.execute()); SuccessfulCacheableCommand command2 = new SuccessfulCacheableCommand(circuitBreaker, true, "two"); - assertEquals(true, command2.queue().get()); + assertEquals("two", command2.queue().get()); fail("We expect an exception because cacheKey requires RequestVariable."); @@ -6288,15 +6288,15 @@ protected Boolean run() throws Exception { } enum CommandKeyForUnitTest implements HystrixCommandKey { - KEY_ONE, KEY_TWO; + KEY_ONE, KEY_TWO } enum CommandGroupForUnitTest implements HystrixCommandGroupKey { - OWNER_ONE, OWNER_TWO; + OWNER_ONE, OWNER_TWO } enum ThreadPoolKeyForUnitTest implements HystrixThreadPoolKey { - THREAD_POOL_ONE, THREAD_POOL_TWO; + THREAD_POOL_ONE, THREAD_POOL_TWO } private static HystrixPropertiesStrategy TEST_PROPERTIES_FACTORY = new TestPropertiesFactory(); diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCollapserTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCollapserTest.java index 7597915fe..f90689105 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCollapserTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCollapserTest.java @@ -209,7 +209,7 @@ public void call(Subscriber s) { if (request.getArgument() == null) { throw new NullPointerException("Simulated Error"); } - if (request.getArgument() == "TIMEOUT") { + if (request.getArgument().equals("TIMEOUT")) { try { Thread.sleep(200); } catch (InterruptedException e) { diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java index 5ea8c08e8..4ff8a9ccf 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java @@ -55,7 +55,6 @@ import com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable; import com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler; import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext; -import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; import com.netflix.hystrix.strategy.properties.HystrixProperty; import com.netflix.hystrix.util.HystrixRollingNumberEvent; @@ -2739,10 +2738,10 @@ public void testCacheKeyExecutionRequiresRequestVariable() { TestCircuitBreaker circuitBreaker = new TestCircuitBreaker(); SuccessfulCacheableCommand command = new SuccessfulCacheableCommand(circuitBreaker, true, "one"); - assertEquals(true, command.observe().toBlocking().single()); + assertEquals("one", command.observe().toBlocking().single()); SuccessfulCacheableCommand command2 = new SuccessfulCacheableCommand(circuitBreaker, true, "two"); - assertEquals(true, command2.observe().toBlocking().toFuture().get()); + assertEquals("two", command2.observe().toBlocking().toFuture().get()); fail("We expect an exception because cacheKey requires RequestVariable."); @@ -7187,7 +7186,7 @@ public KnownFailureThreadIsolatedTestCommandWithFallback(TestCircuitBreaker circ @Override protected Observable construct() { - return Observable.error(new RuntimeException("we failed with a simulated async issue")); + return Observable.error(new RuntimeException("we failed with a simulated async issue")); } @Override @@ -7215,7 +7214,7 @@ public Observable call() { } catch (InterruptedException ie) { return Observable.error(ie); } - return Observable.error(new RuntimeException("we failed with a simulated async issue")); + return Observable.error(new RuntimeException("we failed with a simulated async issue")); } }); } @@ -7245,7 +7244,7 @@ public Observable call() { } catch (InterruptedException ie) { return Observable.error(ie); } - return Observable.error(new RuntimeException("we failed with a simulated async issue")); + return Observable.error(new RuntimeException("we failed with a simulated async issue")); } }); } @@ -7294,12 +7293,12 @@ public KnownFailureThreadIsolatedTestCommandWithFailingFallback(TestCircuitBreak @Override protected Observable construct() { - return Observable.error(new RuntimeException("we failed with a simulated async issue")); + return Observable.error(new RuntimeException("we failed with a simulated async issue")); } @Override protected Observable resumeWithFallback() { - return Observable.error(new RuntimeException("we failed with a simulated async fallback issue")); + return Observable.error(new RuntimeException("we failed with a simulated async fallback issue")); } } @@ -7314,7 +7313,7 @@ public KnownFailureThreadIsolatedTestCommandWithNoFallback(TestCircuitBreaker ci @Override protected Observable construct() { - return Observable.error(new RuntimeException("we failed with a simulated async issue")); + return Observable.error(new RuntimeException("we failed with a simulated async issue")); } } @@ -8086,15 +8085,15 @@ protected Observable construct() { } enum CommandKeyForUnitTest implements HystrixCommandKey { - KEY_ONE, KEY_TWO; + KEY_ONE, KEY_TWO } enum CommandGroupForUnitTest implements HystrixCommandGroupKey { - OWNER_ONE, OWNER_TWO; + OWNER_ONE, OWNER_TWO } enum ThreadPoolKeyForUnitTest implements HystrixThreadPoolKey { - THREAD_POOL_ONE, THREAD_POOL_TWO; + THREAD_POOL_ONE, THREAD_POOL_TWO } private static HystrixPropertiesStrategy TEST_PROPERTIES_FACTORY = new TestPropertiesFactory(); diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixTest.java index 3e5e5c53b..b009dcdfb 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixTest.java @@ -1,14 +1,8 @@ package com.netflix.hystrix; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import org.junit.Before; -import org.junit.Test; import com.netflix.hystrix.HystrixCommand.Setter; -import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy; public class HystrixTest { @Before diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolMetricsTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolMetricsTest.java index 2cab94b43..b0a170a63 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolMetricsTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolMetricsTest.java @@ -1,6 +1,5 @@ package com.netflix.hystrix; -import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolTest.java index 3a79386ba..1eb1affdd 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixThreadPoolTest.java @@ -8,10 +8,8 @@ import com.netflix.hystrix.HystrixThreadPool.Factory; import com.netflix.hystrix.strategy.HystrixPlugins; -import com.netflix.hystrix.strategy.HystrixPluginsTest; import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher; import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherFactory; -import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherFactoryTest; import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherThreadPool; import org.junit.Before; import org.junit.Test; diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/strategy/HystrixPluginsTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/strategy/HystrixPluginsTest.java index 937a9c0c0..c2d4e1f61 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/strategy/HystrixPluginsTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/strategy/HystrixPluginsTest.java @@ -1,30 +1,16 @@ package com.netflix.hystrix.strategy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicReference; import org.junit.After; -import org.junit.Test; - -import rx.functions.Action1; -import com.netflix.hystrix.Hystrix; import com.netflix.hystrix.HystrixCommand; import com.netflix.hystrix.HystrixCommandGroupKey; import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy; -import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategyDefault; -import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext; import com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier; -import com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifierDefault; import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; -import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHookDefault; import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher; -import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherDefault; import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; -import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategyDefault; public class HystrixPluginsTest { @After diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactoryTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactoryTest.java index 0ae6b6139..7971315e3 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactoryTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactoryTest.java @@ -121,11 +121,11 @@ public void initialize() { } private static enum TestCommandKey implements HystrixCommandKey { - TEST_A, TEST_B; + TEST_A, TEST_B } private static enum TestThreadPoolKey implements HystrixThreadPoolKey { - TEST_A, TEST_B; + TEST_A, TEST_B } static class CustomPublisher extends HystrixMetricsPublisher{ diff --git a/hystrix-core/src/test/java/com/netflix/hystrix/util/HystrixRollingPercentileTest.java b/hystrix-core/src/test/java/com/netflix/hystrix/util/HystrixRollingPercentileTest.java index 6a82e1d3a..8abc361fa 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/util/HystrixRollingPercentileTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/util/HystrixRollingPercentileTest.java @@ -183,8 +183,7 @@ public void testSampleDataOverTime2() { } public PercentileSnapshot getPercentileForValues(int... values) { - PercentileSnapshot p = new PercentileSnapshot(values); - return p; + return new PercentileSnapshot(values); } @Test