Skip to content

Commit

Permalink
Revert back to JDK6
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Jacobs committed Mar 27, 2015
1 parent 7983885 commit 31e92dc
Show file tree
Hide file tree
Showing 54 changed files with 197 additions and 187 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ subprojects {
apply plugin: 'java'
apply plugin: 'nebula.provided-base'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.6
targetCompatibility = 1.6

repositories {
jcenter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static CacheInvocationContext<CacheResult> createCacheResultInvocationCon
Method method = metaHolder.getMethod();
CacheResult cacheResult = method.getAnnotation(CacheResult.class);
MethodExecutionAction cacheKeyMethod = createCacheKeyAction(cacheResult.cacheKeyMethod(), metaHolder);
return new CacheInvocationContext<>(cacheResult, cacheKeyMethod, metaHolder.getObj(), method, metaHolder.getArgs());
return new CacheInvocationContext<CacheResult>(cacheResult, cacheKeyMethod, metaHolder.getObj(), method, metaHolder.getArgs());
}
return null;
}
Expand All @@ -60,7 +60,7 @@ public static CacheInvocationContext<CacheRemove> createCacheRemoveInvocationCon
Method method = metaHolder.getMethod();
CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class);
MethodExecutionAction cacheKeyMethod = createCacheKeyAction(cacheRemove.cacheKeyMethod(), metaHolder);
return new CacheInvocationContext<>(cacheRemove, cacheKeyMethod, metaHolder.getObj(), method, metaHolder.getArgs());
return new CacheInvocationContext<CacheRemove>(cacheRemove, cacheKeyMethod, metaHolder.getObj(), method, metaHolder.getArgs());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ private Object getPropertyValue(String name, Object obj) throws HystrixCacheKeyG
try {
return new PropertyDescriptor(name, obj.getClass())
.getReadMethod().invoke(obj);
} catch (IllegalAccessException | IntrospectionException | InvocationTargetException e) {
} catch (IllegalAccessException e) {
throw new HystrixCacheKeyGenerationException(e);
} catch (IntrospectionException e) {
throw new HystrixCacheKeyGenerationException(e);
} catch (InvocationTargetException e) {
throw new HystrixCacheKeyGenerationException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ private Object execute(Object o, Method m, Object... args) throws CommandActionE
try {
m.setAccessible(true); // suppress Java language access
result = m.invoke(o, args);
} catch (IllegalAccessException | InvocationTargetException e) {
} catch (IllegalAccessException e) {
propagateCause(e);
} catch (InvocationTargetException e) {
propagateCause(e);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void testGetUserByName_givenNonexistentCacheKeyMethod_shouldThrowExceptio
}

public static class UserService {
private Map<String, User> storage = new ConcurrentHashMap<>();
private Map<String, User> storage = new ConcurrentHashMap<String, User>();

@PostConstruct
private void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class ErrorPropagationTest {
private static final Map<String, User> USERS;

static {
USERS = new HashMap<>();
USERS = new HashMap<String, User>();
USERS.put("1", new User("1", "user_1"));
USERS.put("2", new User("2", "user_2"));
USERS.put("3", new User("3", "user_3"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static class MetricJsonListener implements HystrixMetricsPoller.MetricsA
* <p>
* This is a safety check against a runaway poller causing memory leaks.
*/
private final LinkedBlockingQueue<String> jsonMetrics = new LinkedBlockingQueue<>(1000);
private final LinkedBlockingQueue<String> jsonMetrics = new LinkedBlockingQueue<String>(1000);

/**
* Store JSON messages in a queue.
Expand All @@ -219,7 +219,7 @@ public void handleJsonMetric(String json) {
* @return
*/
public List<String> getJsonMetrics() {
ArrayList<String> metrics = new ArrayList<>();
ArrayList<String> metrics = new ArrayList<String>();
jsonMetrics.drainTo(metrics);
return metrics;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private HttpServer<ByteBuf, ByteBuf> createServer() {
for (int i = 0; i < 3 && server == null; i++) {
port = 10000 + random.nextInt(50000);
try {
return RxNetty.newHttpServerBuilder(port, new HystrixMetricsStreamHandler<>(
return RxNetty.newHttpServerBuilder(port, new HystrixMetricsStreamHandler<ByteBuf, ByteBuf>(
DEFAULT_HYSTRIX_PREFIX,
DEFAULT_INTERVAL,
new RequestHandler<ByteBuf, ByteBuf>() { // Application handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected Tag getServoInstanceTag() {
*/
private List<Monitor<?>> getServoMonitors() {

List<Monitor<?>> monitors = new ArrayList<>();
List<Monitor<?>> monitors = new ArrayList<Monitor<?>>();

monitors.add(new InformationalMetric<String>(MonitorConfig.builder("name").build()) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected Tag getServoInstanceTag() {
*/
private List<Monitor<?>> getServoMonitors() {

List<Monitor<?>> monitors = new ArrayList<>();
List<Monitor<?>> monitors = new ArrayList<Monitor<?>>();

monitors.add(new InformationalMetric<Boolean>(MonitorConfig.builder("isCircuitBreakerOpen").build()) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected Tag getServoInstanceTag() {
*/
private List<Monitor<?>> getServoMonitors() {

List<Monitor<?>> monitors = new ArrayList<>();
List<Monitor<?>> monitors = new ArrayList<Monitor<?>>();

monitors.add(new InformationalMetric<String>(MonitorConfig.builder("name").build()) {
@Override
Expand Down
24 changes: 12 additions & 12 deletions hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ protected static enum TimedOutStatus {
/* FALLBACK Semaphore */
protected final TryableSemaphore fallbackSemaphoreOverride;
/* each circuit has a semaphore to restrict concurrent fallback execution */
protected static final ConcurrentHashMap<String, TryableSemaphore> fallbackSemaphorePerCircuit = new ConcurrentHashMap<>();
protected static final ConcurrentHashMap<String, TryableSemaphore> fallbackSemaphorePerCircuit = new ConcurrentHashMap<String, TryableSemaphore>();
/* END FALLBACK Semaphore */

/* EXECUTION Semaphore */
protected final TryableSemaphore executionSemaphoreOverride;
/* each circuit has a semaphore to restrict concurrent fallback execution */
protected static final ConcurrentHashMap<String, TryableSemaphore> executionSemaphorePerCircuit = new ConcurrentHashMap<>();
protected static final ConcurrentHashMap<String, TryableSemaphore> executionSemaphorePerCircuit = new ConcurrentHashMap<String, TryableSemaphore>();
/* END EXECUTION Semaphore */

protected final AtomicReference<Reference<TimerListener>> timeoutTimer = new AtomicReference<>();
protected final AtomicReference<Reference<TimerListener>> timeoutTimer = new AtomicReference<Reference<TimerListener>>();

protected AtomicBoolean started = new AtomicBoolean();
protected volatile long invocationStartTime = -1;
Expand All @@ -105,10 +105,10 @@ protected static enum TimedOutStatus {
protected volatile ExecutionResult executionResult = ExecutionResult.EMPTY;

/* If this command executed and timed-out */
protected final AtomicReference<TimedOutStatus> isCommandTimedOut = new AtomicReference<>(TimedOutStatus.NOT_EXECUTED);
protected final AtomicReference<TimedOutStatus> isCommandTimedOut = new AtomicReference<TimedOutStatus>(TimedOutStatus.NOT_EXECUTED);
protected final AtomicBoolean isExecutionComplete = new AtomicBoolean(false);
protected final AtomicBoolean isExecutedInThread = new AtomicBoolean(false);
protected final AtomicReference<Action0> endCurrentThreadExecutingCommand = new AtomicReference<>(); // don't like how this is being done
protected final AtomicReference<Action0> endCurrentThreadExecutingCommand = new AtomicReference<Action0>(); // don't like how this is being done


/**
Expand All @@ -119,7 +119,7 @@ protected static enum TimedOutStatus {

// this is a micro-optimization but saves about 1-2microseconds (on 2011 MacBook Pro)
// on the repetitive string processing that will occur on the same classes over and over again
private static ConcurrentHashMap<Class<?>, String> defaultNameCache = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Class<?>, String> defaultNameCache = new ConcurrentHashMap<Class<?>, String>();

/* package */static String getDefaultNameFromClass(Class<?> cls) {
String fromCache = defaultNameCache.get(cls);
Expand Down Expand Up @@ -360,7 +360,7 @@ public Observable<R> toObservable() {
metrics.markResponseFromCache();
isExecutionComplete.set(true);
executionHook.onCacheHit(this);
return new CachedObservableResponse<>((CachedObservableOriginal<R>) fromCache, this);
return new CachedObservableResponse<R>((CachedObservableOriginal<R>) fromCache, this);
}
}

Expand Down Expand Up @@ -470,17 +470,17 @@ public void call() {
// put in cache
if (isRequestCachingEnabled()) {
// wrap it for caching
o = new CachedObservableOriginal<>(o.cache(), this);
o = new CachedObservableOriginal<R>(o.cache(), this);
Observable<R> fromCache = requestCache.putIfAbsent(getCacheKey(), o);
if (fromCache != null) {
// another thread beat us so we'll use the cached value instead
o = new CachedObservableResponse<>((CachedObservableOriginal<R>) fromCache, this);
o = new CachedObservableResponse<R>((CachedObservableOriginal<R>) fromCache, this);
}
// we just created an ObservableCommand so we cast and return it
return o;
} else {
// no request caching so a simple wrapper just to pass 'this' along with the Observable
return new ObservableCommand<>(o, this);
return new ObservableCommand<R>(o, this);
}
}

Expand Down Expand Up @@ -542,7 +542,7 @@ public void call(Notification<? super R> n) {
}


}).lift(new HystrixObservableTimeoutOperator<>(_self)).doOnNext(new Action1<R>() {
}).lift(new HystrixObservableTimeoutOperator<R>(_self)).doOnNext(new Action1<R>() {
@Override
public void call(R r) {
if (shouldOutputOnNextEvents()) {
Expand Down Expand Up @@ -1669,7 +1669,7 @@ public ExecutionResult addEvents(HystrixEventType... events) {
}

private static List<HystrixEventType> getUpdatedList(List<HystrixEventType> currentList, HystrixEventType... newEvents) {
ArrayList<HystrixEventType> updatedEvents = new ArrayList<>();
ArrayList<HystrixEventType> updatedEvents = new ArrayList<HystrixEventType>();
updatedEvents.addAll(currentList);
Collections.addAll(updatedEvents, newEvents);
return Collections.unmodifiableList(updatedEvents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private static void _reset() {
private static ThreadLocal<LinkedList<HystrixCommandKey>> currentCommand = new ThreadLocal<LinkedList<HystrixCommandKey>>() {
@Override
protected LinkedList<HystrixCommandKey> initialValue() {
return new LinkedList<>();
return new LinkedList<HystrixCommandKey>();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface HystrixCircuitBreaker {
*/
public static class Factory {
// String is HystrixCommandKey.name() (we can't use HystrixCommandKey directly as we can't guarantee it implements hashcode/equals correctly)
private static ConcurrentHashMap<String, HystrixCircuitBreaker> circuitBreakersByCommand = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HystrixCircuitBreaker> circuitBreakersByCommand = new ConcurrentHashMap<String, HystrixCircuitBreaker>();

/**
* Get the {@link HystrixCircuitBreaker} instance for a given {@link HystrixCommandKey}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected HystrixCollapser(Setter setter) {
}

HystrixCollapserProperties properties = HystrixPropertiesFactory.getCollapserProperties(collapserKey, propertiesBuilder);
this.collapserFactory = new RequestCollapserFactory<>(collapserKey, scope, timer, properties);
this.collapserFactory = new RequestCollapserFactory<BatchReturnType, ResponseType, RequestArgumentType>(collapserKey, scope, timer, properties);
this.requestCache = HystrixRequestCache.getInstance(collapserKey, HystrixPlugins.getInstance().getConcurrencyStrategy());

if (metrics == null) {
Expand Down Expand Up @@ -592,6 +592,6 @@ public Setter andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter p
// this is a micro-optimization but saves about 1-2microseconds (on 2011 MacBook Pro)
// on the repetitive string processing that will occur on the same classes over and over again
@SuppressWarnings("rawtypes")
private static ConcurrentHashMap<Class<? extends HystrixCollapser>, String> defaultNameCache = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Class<? extends HystrixCollapser>, String> defaultNameCache = new ConcurrentHashMap<Class<? extends HystrixCollapser>, String>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private Factory() {
}

// used to intern instances so we don't keep re-creating them millions of times for the same key
private static ConcurrentHashMap<String, HystrixCollapserKey> intern = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HystrixCollapserKey> intern = new ConcurrentHashMap<String, HystrixCollapserKey>();

/**
* Retrieve (or create) an interned HystrixCollapserKey instance for a given name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class HystrixCollapserMetrics extends HystrixMetrics {
private static final Logger logger = LoggerFactory.getLogger(HystrixCollapserMetrics.class);

// String is HystrixCollapserKey.name() (we can't use HystrixCollapserKey directly as we can't guarantee it implements hashcode/equals correctly)
private static final ConcurrentHashMap<String, HystrixCollapserMetrics> metrics = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, HystrixCollapserMetrics> metrics = new ConcurrentHashMap<String, HystrixCollapserMetrics>();

/**
* Get or create the {@link HystrixCollapserMetrics} instance for a given {@link HystrixCollapserKey}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private Factory() {
}

// used to intern instances so we don't keep re-creating them millions of times for the same key
private static ConcurrentHashMap<String, HystrixCommandGroupKey> intern = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HystrixCommandGroupKey> intern = new ConcurrentHashMap<String, HystrixCommandGroupKey>();

/**
* Retrieve (or create) an interned HystrixCommandGroup instance for a given name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private Factory() {
}

// used to intern instances so we don't keep re-creating them millions of times for the same key
private static ConcurrentHashMap<String, HystrixCommandKey> intern = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HystrixCommandKey> intern = new ConcurrentHashMap<String, HystrixCommandKey>();

/**
* Retrieve (or create) an interned HystrixCommandKey instance for a given name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class HystrixCommandMetrics extends HystrixMetrics {
private static final Logger logger = LoggerFactory.getLogger(HystrixCommandMetrics.class);

// String is HystrixCommandKey.name() (we can't use HystrixCommandKey directly as we can't guarantee it implements hashcode/equals correctly)
private static final ConcurrentHashMap<String, HystrixCommandMetrics> metrics = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, HystrixCommandMetrics> metrics = new ConcurrentHashMap<String, HystrixCommandMetrics>();

/**
* Get or create the {@link HystrixCommandMetrics} instance for a given {@link HystrixCommandKey}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected HystrixObservableCollapser(Setter setter) {
}

HystrixCollapserProperties properties = HystrixPropertiesFactory.getCollapserProperties(collapserKey, propertiesBuilder);
this.collapserFactory = new RequestCollapserFactory<>(collapserKey, scope, timer, properties);
this.collapserFactory = new RequestCollapserFactory<BatchReturnType, ResponseType, RequestArgumentType>(collapserKey, scope, timer, properties);
this.requestCache = HystrixRequestCache.getInstance(collapserKey, HystrixPlugins.getInstance().getConcurrencyStrategy());

if (metrics == null) {
Expand Down Expand Up @@ -169,7 +169,7 @@ public Observable<Void> mapResponseToRequests(Observable<BatchReturnType> batchR
final Func1<BatchReturnType, ResponseType> mapBatchTypeToResponseType = self.getBatchReturnTypeToResponseTypeMapper();

// index the requests by key
final Map<K, CollapsedRequest<ResponseType, RequestArgumentType>> requestsByKey = new HashMap<>(requests.size());
final Map<K, CollapsedRequest<ResponseType, RequestArgumentType>> requestsByKey = new HashMap<K, CollapsedRequest<ResponseType, RequestArgumentType>>(requests.size());
for (CollapsedRequest<ResponseType, RequestArgumentType> cr : requests) {
requestsByKey.put(requestKeySelector.call(cr.getArgument()), cr);
}
Expand Down Expand Up @@ -531,6 +531,6 @@ public Setter andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter p
// this is a micro-optimization but saves about 1-2microseconds (on 2011 MacBook Pro)
// on the repetitive string processing that will occur on the same classes over and over again
@SuppressWarnings("rawtypes")
private static ConcurrentHashMap<Class<? extends HystrixObservableCollapser>, String> defaultNameCache = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Class<? extends HystrixObservableCollapser>, String> defaultNameCache = new ConcurrentHashMap<Class<? extends HystrixObservableCollapser>, String>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class HystrixRequestCache {
private static final Logger logger = LoggerFactory.getLogger(HystrixRequestCache.class);

// the String key must be: HystrixRequestCache.prefix + concurrencyStrategy + cacheKey
private final static ConcurrentHashMap<RequestCacheKey, HystrixRequestCache> caches = new ConcurrentHashMap<>();
private final static ConcurrentHashMap<RequestCacheKey, HystrixRequestCache> caches = new ConcurrentHashMap<RequestCacheKey, HystrixRequestCache>();

private final RequestCacheKey rcKey;
private final HystrixConcurrencyStrategy concurrencyStrategy;
Expand All @@ -47,11 +47,11 @@ public class HystrixRequestCache {
* <p>
* Key => CommandPrefix + CacheKey : Future<?> from queue()
*/
private static final HystrixRequestVariableHolder<ConcurrentHashMap<ValueCacheKey, Observable<?>>> requestVariableForCache = new HystrixRequestVariableHolder<>(new HystrixRequestVariableLifecycle<ConcurrentHashMap<ValueCacheKey, Observable<?>>>() {
private static final HystrixRequestVariableHolder<ConcurrentHashMap<ValueCacheKey, Observable<?>>> requestVariableForCache = new HystrixRequestVariableHolder<ConcurrentHashMap<ValueCacheKey, Observable<?>>>(new HystrixRequestVariableLifecycle<ConcurrentHashMap<ValueCacheKey, Observable<?>>>() {

@Override
public ConcurrentHashMap<ValueCacheKey, Observable<?>> initialValue() {
return new ConcurrentHashMap<>();
return new ConcurrentHashMap<ValueCacheKey, Observable<?>>();
}

@Override
Expand Down
Loading

0 comments on commit 31e92dc

Please sign in to comment.