From bc2746c2d00bd62f1be12249430abced787543e3 Mon Sep 17 00:00:00 2001 From: Matt Jacobs Date: Mon, 2 Mar 2015 16:27:13 -0800 Subject: [PATCH] Fix Javadoc warnings --- .../com/netflix/hystrix/AbstractCommand.java | 12 ++---- .../com/netflix/hystrix/HystrixCollapser.java | 2 +- .../netflix/hystrix/HystrixCollapserKey.java | 2 +- .../hystrix/HystrixCollapserProperties.java | 2 +- .../hystrix/HystrixCommandGroupKey.java | 2 +- .../netflix/hystrix/HystrixCommandKey.java | 2 +- .../hystrix/HystrixCommandMetrics.java | 8 ++-- .../hystrix/HystrixObservableCollapser.java | 2 +- .../netflix/hystrix/HystrixThreadPoolKey.java | 2 +- .../hystrix/HystrixThreadPoolProperties.java | 2 +- .../CollapsedRequestObservableFunction.java | 6 +-- .../hystrix/collapser/RequestBatch.java | 1 - .../hystrix/collapser/RequestCollapser.java | 11 +++--- .../collapser/RequestCollapserFactory.java | 4 +- .../eventnotifier/HystrixEventNotifier.java | 4 +- ...trixPropertiesChainedArchaiusProperty.java | 4 +- .../properties/HystrixPropertiesStrategy.java | 16 ++++---- .../strategy/properties/HystrixProperty.java | 2 +- .../hystrix/util/HystrixRollingNumber.java | 6 +-- .../util/HystrixRollingPercentile.java | 4 +- .../netflix/hystrix/HystrixCollapserTest.java | 2 +- .../hystrix/HystrixCommandPropertiesTest.java | 2 +- .../netflix/hystrix/HystrixCommandTest.java | 37 ++++++++++++++++++- .../hystrix/HystrixObservableCommandTest.java | 4 +- 24 files changed, 83 insertions(+), 56 deletions(-) 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 5cccab932..edfb31683 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java @@ -278,7 +278,7 @@ protected AbstractCommand(HystrixCommandGroupKey group, HystrixCommandKey key, H /** * Allow the Collapser to mark this command instance as being used for a collapsed request and how many requests were collapsed. * - * @param sizeOfBatch + * @param sizeOfBatch number of commands in request batch */ /* package */void markAsCollapsedCommand(int sizeOfBatch) { getMetrics().markCollapsed(sizeOfBatch); @@ -955,8 +955,6 @@ private static void setRequestContextIfNeeded(final HystrixRequestContext curren /** * Get the TryableSemaphore this HystrixCommand should use if a fallback occurs. * - * @param circuitBreaker - * @param fallbackSemaphore * @return TryableSemaphore */ protected TryableSemaphore getFallbackSemaphore() { @@ -978,8 +976,6 @@ protected TryableSemaphore getFallbackSemaphore() { /** * Get the TryableSemaphore this HystrixCommand should use for execution if not running in a separate thread. * - * @param circuitBreaker - * @param fallbackSemaphore * @return TryableSemaphore */ protected TryableSemaphore getExecutionSemaphore() { @@ -1469,7 +1465,7 @@ private R wrapWithOnEmitHook(R r) { *

* This will only throw an HystrixRuntimeException, HystrixBadRequestException or IllegalStateException * - * @param e + * @param e initial exception * @return HystrixRuntimeException, HystrixBadRequestException or IllegalStateException */ protected RuntimeException decomposeException(Exception e) { @@ -1661,8 +1657,8 @@ private ExecutionResult(List events, int executionTime, Except /** * Creates a new ExecutionResult by adding the defined 'events' to the ones on the current instance. * - * @param events - * @return + * @param events events to add + * @return new {@link com.netflix.hystrix.AbstractCommand.ExecutionResult} with events added */ public ExecutionResult addEvents(HystrixEventType... events) { return new ExecutionResult(getUpdatedList(this.events, events), executionTime, exception, numEmissions, numFallbackEmissions); 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 42e4a2f93..8aa8d17ec 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapser.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapser.java @@ -519,7 +519,7 @@ public interface CollapsedRequest { /** * When set any client thread blocking on get() will immediately be unblocked and receive the exception. * - * @param exception + * @param exception exception to set on response * @throws IllegalStateException * if called more than once or after setResponse. */ diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserKey.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserKey.java index 1963425af..bdac217b2 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserKey.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserKey.java @@ -42,7 +42,7 @@ private Factory() { /** * Retrieve (or create) an interned HystrixCollapserKey instance for a given name. * - * @param name + * @param name collapser name * @return HystrixCollapserKey instance that is interned (cached) so a given name will always retrieve the same instance. */ public static HystrixCollapserKey asKey(String name) { 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 d2deb243a..00704f08d 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserProperties.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserProperties.java @@ -325,7 +325,7 @@ public Setter withMetricsRollingPercentileWindowBuckets(int value) { * Return a static representation of the properties with values from the Builder so that UnitTests can create properties that are not affected by the actual implementations which pick up their * values dynamically. * - * @param builder + * @param builder collapser properties builder * @return HystrixCollapserProperties */ /* package */static HystrixCollapserProperties asMock(final Setter builder) { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandGroupKey.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandGroupKey.java index 06d91439b..bb3533871 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandGroupKey.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandGroupKey.java @@ -44,7 +44,7 @@ private Factory() { /** * Retrieve (or create) an interned HystrixCommandGroup instance for a given name. * - * @param name + * @param name command group name * @return HystrixCommandGroup instance that is interned (cached) so a given name will always retrieve the same instance. */ public static HystrixCommandGroupKey asKey(String name) { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandKey.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandKey.java index 22d769f82..c89461d7c 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandKey.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandKey.java @@ -42,7 +42,7 @@ private Factory() { /** * Retrieve (or create) an interned HystrixCommandKey instance for a given name. * - * @param name + * @param name command name * @return HystrixCommandKey instance that is interned (cached) so a given name will always retrieve the same instance. */ public static HystrixCommandKey asKey(String name) { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java index bdecc376b..c630d20f8 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java @@ -226,7 +226,7 @@ public int getCurrentConcurrentExecutionCount() { /** * When a {@link HystrixCommand} successfully completes it will call this method to report its success along with how long the execution took. * - * @param duration + * @param duration command duration */ /* package */void markSuccess(long duration) { eventNotifier.markEvent(HystrixEventType.SUCCESS, key); @@ -236,7 +236,7 @@ public int getCurrentConcurrentExecutionCount() { /** * When a {@link HystrixCommand} fails to complete it will call this method to report its failure along with how long the execution took. * - * @param duration + * @param duration command duration */ /* package */void markFailure(long duration) { eventNotifier.markEvent(HystrixEventType.FAILURE, key); @@ -247,7 +247,7 @@ public int getCurrentConcurrentExecutionCount() { * When a {@link HystrixCommand} times out (fails to complete) it will call this method to report its failure along with how long the command waited (this time should equal or be very close to the * timeout value). * - * @param duration + * @param duration command duration */ /* package */void markTimeout(long duration) { eventNotifier.markEvent(HystrixEventType.TIMEOUT, key); @@ -341,7 +341,7 @@ public long getRollingMaxConcurrentExecutions() { /** * When a command is fronted by an {@link HystrixCollapser} then this marks how many requests are collapsed into the single command execution. * - * @param numRequestsCollapsedToBatch + * @param numRequestsCollapsedToBatch number of requests which got batched */ /* package */void markCollapsed(int numRequestsCollapsedToBatch) { eventNotifier.markEvent(HystrixEventType.COLLAPSED, key); 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 43b751b11..d1fc5543e 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCollapser.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCollapser.java @@ -503,7 +503,7 @@ public static Setter withCollapserKey(HystrixCollapserKey collapserKey) { /** * {@link Scope} defining what scope the collapsing should occur within * - * @param scope + * @param scope collapser scope * * @return Setter for fluent interface via method chaining */ diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolKey.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolKey.java index 1b56351c8..15e5cd6c0 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolKey.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolKey.java @@ -44,7 +44,7 @@ private Factory() { /** * Retrieve (or create) an interned HystrixThreadPoolKey instance for a given name. * - * @param name + * @param name thread pool name * @return HystrixThreadPoolKey instance that is interned (cached) so a given name will always retrieve the same instance. */ public static HystrixThreadPoolKey asKey(String name) { 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 c596cac13..807fb0b88 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolProperties.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPoolProperties.java @@ -249,7 +249,7 @@ public Setter withMetricsRollingStatisticalWindowBuckets(int value) { * Return a static representation of the properties with values from the Builder so that UnitTests can create properties that are not affected by the actual implementations which pick up their * values dynamically. * - * @param builder + * @param builder builder for a {@link HystrixThreadPoolProperties} * @return HystrixThreadPoolProperties */ /* package */static HystrixThreadPoolProperties asMock(final Setter builder) { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapsedRequestObservableFunction.java b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapsedRequestObservableFunction.java index 68a9f153e..bc7c6ebe6 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapsedRequestObservableFunction.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapsedRequestObservableFunction.java @@ -59,7 +59,7 @@ public R getArgument() { * * @throws IllegalStateException * if called more than once or after setException. - * @param response + * @param response response to give to initial command */ @Override public void setResponse(T response) { @@ -89,7 +89,7 @@ public void setResponse(T response) { /** * Set an exception if a response is not yet received otherwise skip it * - * @param e + * @param e synthetic error to set on initial command when no actual response is available */ public void setExceptionIfResponseNotReceived(Exception e) { while (true) { @@ -139,7 +139,7 @@ public Exception setExceptionIfResponseNotReceived(Exception e, String exception * * @throws IllegalStateException * if called more than once or after setResponse. - * @param response + * @param e received exception that gets set on the initial command */ @Override public void setException(Exception e) { 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 1a0e056b5..a98f8380d 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 @@ -103,7 +103,6 @@ public Observable offer(RequestArgumentType arg) { * think a response was never received and will either block indefinitely or will timeout while waiting. * * - * @param args */ public void executeBatchIfNotAlreadyStarted() { /* diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapser.java b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapser.java index 84d7ca037..7d5c3ba3d 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapser.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapser.java @@ -53,11 +53,10 @@ public class RequestCollapser commandCollapser, HystrixCollapserProperties properties, CollapserTimer timer, HystrixConcurrencyStrategy concurrencyStrategy) { this.commandCollapser = commandCollapser; // the command with implementation of abstract methods we need @@ -70,7 +69,7 @@ public class RequestCollapser * @throws IllegalStateException * if submitting after shutdown 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 7a46de60d..c1f610d90 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 @@ -136,7 +136,7 @@ private RequestCollapser get /** * Lookup (or create and store) the RequestVariable for a given HystrixCollapserKey. * - * @param key + * @param commandCollapser collapser to retrieve {@link HystrixRequestVariableHolder} for * @return HystrixRequestVariableHolder */ @SuppressWarnings("unchecked") @@ -259,7 +259,7 @@ public static Setter withCollapserKey(HystrixCollapserKey collapserKey) { /** * {@link Scope} defining what scope the collapsing should occur within * - * @param scope + * @param scope collapser scope * * @return Setter for fluent interface via method chaining */ diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/HystrixEventNotifier.java b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/HystrixEventNotifier.java index c2e5a4931..60b79e859 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/HystrixEventNotifier.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/HystrixEventNotifier.java @@ -42,8 +42,8 @@ public abstract class HystrixEventNotifier { *

* Default Implementation: Does nothing * - * @param eventType - * @param key + * @param eventType event type + * @param key event key */ public void markEvent(HystrixEventType eventType, HystrixCommandKey key) { // do nothing diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesChainedArchaiusProperty.java b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesChainedArchaiusProperty.java index e289cb767..88bfa8421 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesChainedArchaiusProperty.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesChainedArchaiusProperty.java @@ -70,7 +70,7 @@ public ChainLink() { } /** - * @param nextProperty + * @param nextProperty next property in the chain */ public ChainLink(ChainLink nextProperty) { next = nextProperty; @@ -110,7 +110,7 @@ public T get() { } /** - * @param r + * @param r callback to execut */ public void addCallback(Runnable r) { callbacks.add(r); diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesStrategy.java b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesStrategy.java index 1e9d6dae9..4d496e3ec 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesStrategy.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesStrategy.java @@ -64,8 +64,8 @@ public HystrixCommandProperties getCommandProperties(HystrixCommandKey commandKe *

* Returns {@link HystrixCommandKey#name()} * - * @param commandKey - * @param builder + * @param commandKey command key used in determining command's cache key + * @param builder builder for {@link HystrixCommandProperties} used in determining command's cache key * @return String value to be used as the cache key of a {@link HystrixCommandProperties} implementation. */ public String getCommandPropertiesCacheKey(HystrixCommandKey commandKey, HystrixCommandProperties.Setter builder) { @@ -102,9 +102,9 @@ public HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey * Default Implementation *

* Returns {@link HystrixThreadPoolKey#name()} - * - * @param threadPoolKey - * @param builder + * + * @param threadPoolKey thread pool key used in determining thread pool's cache key + * @param builder builder for {@link HystrixThreadPoolProperties} used in determining thread pool's cache key * @return String value to be used as the cache key of a {@link HystrixThreadPoolProperties} implementation. */ public String getThreadPoolPropertiesCacheKey(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties.Setter builder) { @@ -141,9 +141,9 @@ public HystrixCollapserProperties getCollapserProperties(HystrixCollapserKey col * Default Implementation *

* Returns {@link HystrixCollapserKey#name()} - * - * @param collapserKey - * @param builder + * + * @param collapserKey collapser key used in determining collapser's cache key + * @param builder builder for {@link HystrixCollapserProperties} used in determining collapser's cache key * @return String value to be used as the cache key of a {@link HystrixCollapserProperties} implementation. */ public String getCollapserPropertiesCacheKey(HystrixCollapserKey collapserKey, HystrixCollapserProperties.Setter builder) { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixProperty.java b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixProperty.java index 5d317f6fe..73804b18d 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixProperty.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixProperty.java @@ -130,7 +130,7 @@ public T get() { /** * When retrieved this will iterate over the contained {@link HystrixProperty} instances until a non-null value is found and return that. * - * @param values + * @param values properties to iterate over * @return first non-null value or null if none found */ @SafeVarargs diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingNumber.java b/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingNumber.java index 707a5ed1e..305ffa7b6 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingNumber.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingNumber.java @@ -114,8 +114,8 @@ public void add(HystrixRollingNumberEvent type, long value) { *

* The {@link HystrixRollingNumberEvent} must be a "max updater" type HystrixRollingNumberEvent.isMaxUpdater() == true. * - * @param type - * @param value + * @param type HystrixRollingNumberEvent defining which counter to retrieve values from + * @param value long value to be given to the max updater */ public void updateRollingMax(HystrixRollingNumberEvent type, long value) { getCurrentBucket().getMaxUpdater(type).update(value); @@ -144,7 +144,7 @@ public void reset() { *

* The {@link HystrixRollingNumberEvent} must be a "counter" type HystrixRollingNumberEvent.isCounter() == true. * - * @param type + * @param type HystrixRollingNumberEvent defining which counter to retrieve values from * @return cumulative sum of all increments and adds for the given {@link HystrixRollingNumberEvent} counter type */ public long getCumulativeSum(HystrixRollingNumberEvent type) { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingPercentile.java b/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingPercentile.java index 07abb0cc4..eb744c7fa 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingPercentile.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/util/HystrixRollingPercentile.java @@ -379,8 +379,8 @@ public int getPercentile(double percentile) { * @see Percentile (Wikipedia) * @see Percentile * - * @param percent - * @return + * @param percent percentile of data desired + * @return data at the asked-for percentile. Interpolation is used if exactness is not possible */ private int computePercentile(double percent) { // Some just-in-case edge cases 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 0c8af7dfb..994d9f3eb 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCollapserTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCollapserTest.java @@ -1224,7 +1224,7 @@ public void clear() { *

* This is because executing multiple times in a tight-loop would not achieve the correct behavior, such as batching, since it will all execute "now" not after intervals of time. * - * @param timeInMilliseconds + * @param timeInMilliseconds amount of time to increment */ public synchronized void incrementTime(int timeInMilliseconds) { for (ATask t : tasks) { 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 9e86de86c..32e2e63e9 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandPropertiesTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandPropertiesTest.java @@ -59,7 +59,7 @@ public class HystrixCommandPropertiesTest { * Return a static representation of the properties with values from the Builder so that UnitTests can create properties that are not affected by the actual implementations which pick up their * values dynamically. * - * @param builder + * @param builder command properties builder * @return HystrixCommandProperties */ /* package */static HystrixCommandProperties asMock(final Setter builder) { 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 76786aba4..3e579ceb0 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java @@ -3438,6 +3438,39 @@ public void onNext(Boolean args) { assertEquals(0, circuitBreaker.metrics.getCurrentConcurrentExecutionCount()); } + @Test + public void testSemaphoreExecutionWithTimeout() { + //TestHystrixCommand cmd = getLatentCommand(ExecutionIsolationStrategy.SEMAPHORE, AbstractTestHystrixCommand.ExecutionResult.SUCCESS, 1000, AbstractTestHystrixCommand.FallbackResult.SUCCESS, 200); + TestHystrixCommand cmd = new InterruptibleCommand(new TestCircuitBreaker(), false); + + System.out.println("Starting command"); + long timeMillis = System.currentTimeMillis(); + try { + cmd.execute(); + fail("Should throw"); + } catch (Throwable t) { + System.out.println("Unsuccessful Execution took : " + (System.currentTimeMillis() - timeMillis)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.SUCCESS)); + assertEquals(1, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.EXCEPTION_THROWN)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.FAILURE)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.BAD_REQUEST)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.FALLBACK_REJECTION)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.FALLBACK_FAILURE)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.SEMAPHORE_REJECTED)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.SHORT_CIRCUITED)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED)); + assertEquals(1, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT)); + assertEquals(0, cmd.metrics.getRollingCount(HystrixRollingNumberEvent.RESPONSE_FROM_CACHE)); + + assertEquals(100, cmd.metrics.getHealthCounts().getErrorPercentage()); + assertEquals(0, cmd.metrics.getCurrentConcurrentExecutionCount()); + + assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size()); + } + + } + /** * Test a java.lang.Error being thrown */ @@ -4677,8 +4710,8 @@ private static class LatchedSemaphoreCommand extends TestHystrixCommand /** * - * @param circuitBreaker - * @param semaphore + * @param circuitBreaker circuit breaker (passed in so it may be shared) + * @param semaphore semaphore (passed in so it may be shared) * @param startLatch * this command calls {@link java.util.concurrent.CountDownLatch#countDown()} immediately * upon running 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 8bad0e0ad..b818cade2 100644 --- a/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java +++ b/hystrix-core/src/test/java/com/netflix/hystrix/HystrixObservableCommandTest.java @@ -6503,8 +6503,8 @@ private static class LatchedSemaphoreCommand extends TestHystrixObservableComman /** * - * @param circuitBreaker - * @param semaphore + * @param circuitBreaker circuit breaker (passed in so it may be shared) + * @param semaphore semaphore (passed in so it may be shared) * @param startLatch * this command calls {@link CountDownLatch#countDown()} immediately * upon running