Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style fixes #583

Merged
merged 10 commits into from
Jan 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,7 +69,7 @@

protected static enum TimedOutStatus {
NOT_EXECUTED, COMPLETED, TIMED_OUT
};
}

protected final HystrixCommandMetrics metrics;

Expand Down Expand Up @@ -480,7 +479,7 @@ public void call() {
o = new CachedObservableResponse<>((CachedObservableOriginal<R>) fromCache, this);
}
// we just created an ObservableCommand so we cast and return it
return (ObservableCommand<R>) o;
return o;
} else {
// no request caching so a simple wrapper just to pass 'this' along with the Observable
return new ObservableCommand<>(o, this);
Expand All @@ -499,7 +498,7 @@ private Observable<R> getRunObservableDecoratedForMetricsAndErrorHandling() {

final HystrixRequestContext currentRequestContext = HystrixRequestContext.getContextForCurrentThread();

Observable<R> run = null;
Observable<R> 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)

Expand Down Expand Up @@ -605,7 +604,7 @@ public Observable<R> 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);
}
Expand Down Expand Up @@ -721,7 +720,7 @@ private Observable<R> getFallbackWithProtection() {
executionHook.onFallbackStart(this);
final AbstractCommand<R> _cmd = this;

Observable<R> fallback = null;
Observable<R> fallback;
try {
fallback = getFallbackObservable();
} catch (Throwable t) {
Expand All @@ -745,7 +744,7 @@ public Observable<R> 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);
}
Expand Down Expand Up @@ -1432,7 +1431,7 @@ private ExecutionResult(List<HystrixEventType> 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.
Expand All @@ -1443,9 +1442,7 @@ private ExecutionResult(List<HystrixEventType> events, int executionTime, Except
public ExecutionResult addEvents(HystrixEventType... events) {
ArrayList<HystrixEventType> 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);
}

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -379,7 +378,7 @@ public Observable<ResponseType> toObservable() {
public Observable<ResponseType> toObservable(Scheduler observeOn) {

/* try from cache first */
if (getProperties().requestCachingEnabled().get()) {
if (getProperties().requestCacheEnabled().get()) {
Observable<ResponseType> fromCache = requestCache.get(getCacheKey());
if (fromCache != null) {
metrics.markResponseFromCache();
Expand All @@ -390,7 +389,7 @@ public Observable<ResponseType> toObservable(Scheduler observeOn) {
RequestCollapser<BatchReturnType, ResponseType, RequestArgumentType> requestCollapser = collapserFactory.getRequestCollapser(collapserInstanceWrapper);
Observable<ResponseType> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public HystrixProperty<Integer> timerDelayInMilliseconds() {
}

private static enum TestHystrixCollapserKey implements HystrixCollapserKey {
TEST;
TEST
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public Observable<ResponseType> toObservable() {
public Observable<ResponseType> toObservable(Scheduler observeOn) {

/* try from cache first */
if (getProperties().requestCachingEnabled().get()) {
if (getProperties().requestCacheEnabled().get()) {
Observable<ResponseType> fromCache = requestCache.get(getCacheKey());
if (fromCache != null) {
/* mark that we received this response from cache */
Expand All @@ -384,7 +384,7 @@ public Observable<ResponseType> toObservable(Scheduler observeOn) {

RequestCollapser<BatchReturnType, ResponseType, RequestArgumentType> requestCollapser = collapserFactory.getRequestCollapser(collapserInstanceWrapper);
Observable<ResponseType> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ConcurrentHashMap<ValueCacheKey, Observable<?>> initialValue() {
@Override
public void shutdown(ConcurrentHashMap<ValueCacheKey, Observable<?>> value) {
// nothing to shutdown
};
}

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public HystrixRequestLog initialValue() {

public void shutdown(HystrixRequestLog value) {
// nothing to shutdown
};
}

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public HystrixProperty<Integer> metricsRollingStatisticalWindowBuckets() {
}

private static enum TestThreadPoolKey implements HystrixThreadPoolKey {
TEST;
TEST
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public T initialValue() {

public void shutdown(T value) {
rv.shutdown(value);
};
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ public void shutdown() {
// being held in ThreadLocals on threads that weren't cleaned up
state = null;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ public void testVoidResponseTypeFireAndForgetCollapsing2() throws Exception {
TestCollapserTimer timer = new TestCollapserTimer();
TestCollapserWithVoidResponseTypeAndMissingMapResponseToRequests collapser1 = new TestCollapserWithVoidResponseTypeAndMissingMapResponseToRequests(timer, 1);
Future<Void> response1 = collapser1.queue();
Future<Void> 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
Expand Down Expand Up @@ -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<HystrixCommand<List<String>>> executionLog) {
Expand Down Expand Up @@ -1096,7 +1095,7 @@ protected List<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public HystrixProperty<Boolean> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void call(Subscriber<? super String> 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) {
Expand Down
Loading