Skip to content

Commit

Permalink
Merge pull request #56 from benjchristensen/plugin-bootstrapping
Browse files Browse the repository at this point in the history
Plugin bootstrapping
  • Loading branch information
benjchristensen committed Dec 18, 2012
2 parents ab1d2b9 + f221f6e commit 646bf0d
Show file tree
Hide file tree
Showing 3 changed files with 344 additions and 96 deletions.
19 changes: 11 additions & 8 deletions hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected HystrixCommand(HystrixCommandGroupKey group) {
*/
protected HystrixCommand(Setter setter) {
// use 'null' to specify use the default
this(setter.groupKey, setter.commandKey, setter.threadPoolKey, null, null, setter.commandPropertiesDefaults, setter.threadPoolPropertiesDefaults, null, null, null);
this(setter.groupKey, setter.commandKey, setter.threadPoolKey, null, null, setter.commandPropertiesDefaults, setter.threadPoolPropertiesDefaults, null, null, null, null);
}

/**
Expand All @@ -165,7 +165,8 @@ protected HystrixCommand(Setter setter) {
*/
private HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore) {
HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
HystrixPropertiesStrategy propertiesStrategy) {
/*
* CommandGroup initialization
*/
Expand All @@ -188,7 +189,12 @@ private HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, Hyst
/*
* Properties initialization
*/
this.properties = HystrixPropertiesFactory.getCommandProperties(this.commandKey, commandPropertiesDefaults);
if (propertiesStrategy == null) {
this.properties = HystrixPropertiesFactory.getCommandProperties(this.commandKey, commandPropertiesDefaults);
} else {
// used for unit testing
this.properties = propertiesStrategy.getCommandProperties(this.commandKey, commandPropertiesDefaults);
}

/*
* ThreadPoolKey
Expand Down Expand Up @@ -1657,7 +1663,6 @@ public static class UnitTest {
public void prepareForTest() {
/* we must call this to simulate a new request lifecycle running and clearing caches */
HystrixRequestContext.initializeContext();
HystrixPlugins.getInstance().registerPropertiesStrategy(TEST_PROPERTIES_FACTORY);
}

@After
Expand All @@ -1670,8 +1675,6 @@ public void cleanup() {

// force properties to be clean as well
ConfigurationManager.getConfigInstance().clear();

HystrixPlugins.getInstance().registerPropertiesStrategy(null);
}

/**
Expand Down Expand Up @@ -3945,7 +3948,7 @@ public void testBasicExecutionWorksWithoutRequestVariable() {

} catch (Exception e) {
e.printStackTrace();
fail("We received an exception.");
fail("We received an exception => " + e.getMessage());
}
}

Expand Down Expand Up @@ -4081,7 +4084,7 @@ public void testBadRequestExceptionViaQueueInSemaphore() {
TestHystrixCommand(TestCommandBuilder builder) {
super(builder.owner, builder.dependencyKey, builder.threadPoolKey, builder.circuitBreaker, builder.threadPool,
builder.commandPropertiesDefaults, builder.threadPoolPropertiesDefaults, builder.metrics,
builder.fallbackSemaphore, builder.executionSemaphore);
builder.fallbackSemaphore, builder.executionSemaphore, TEST_PROPERTIES_FACTORY);
this.builder = builder;
}

Expand Down
Loading

0 comments on commit 646bf0d

Please sign in to comment.