Use diamond operator
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,7 +56,7 @@ public class BackToBackPatternClassifier<C, T> implements Classifier<C, T> {
|
||||
* @param map maps pattern keys with wildcards to output values
|
||||
*/
|
||||
public void setMatcherMap(Map<String, T> map) {
|
||||
this.matcher = new PatternMatchingClassifier<T>(map);
|
||||
this.matcher = new PatternMatchingClassifier<>(map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ public class BackToBackPatternClassifier<C, T> implements Classifier<C, T> {
|
||||
* @param delegate the delegate object used to create a router classifier
|
||||
*/
|
||||
public void setRouterDelegate(Object delegate) {
|
||||
this.router = new ClassifierAdapter<C, String>(delegate);
|
||||
this.router = new ClassifierAdapter<>(delegate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,7 +64,7 @@ public class BinaryExceptionClassifier extends SubclassClassifier<Throwable, Boo
|
||||
public BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses, boolean value) {
|
||||
this(!value);
|
||||
if (exceptionClasses != null) {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
for (Class<? extends Throwable> type : exceptionClasses) {
|
||||
map.put(type, !getDefault());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,7 +52,7 @@ public class BinaryExceptionClassifierBuilder {
|
||||
|
||||
private boolean traverseCauses = false;
|
||||
|
||||
private List<Class<? extends Throwable>> exceptionClasses = new ArrayList<Class<? extends Throwable>>();
|
||||
private List<Class<? extends Throwable>> exceptionClasses = new ArrayList<>();
|
||||
|
||||
public BinaryExceptionClassifierBuilder retryOn(Class<? extends Throwable> throwable) {
|
||||
Assert.isTrue(isWhiteList == null || isWhiteList, "Please use only retryOn() or only notRetryOn()");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,9 +31,9 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class PatternMatcher<S> {
|
||||
|
||||
private Map<String, S> map = new HashMap<String, S>();
|
||||
private Map<String, S> map = new HashMap<>();
|
||||
|
||||
private List<String> sorted = new ArrayList<String>();
|
||||
private List<String> sorted = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Initialize a new {@link PatternMatcher} with a map of patterns to values
|
||||
@@ -43,7 +43,7 @@ public class PatternMatcher<S> {
|
||||
super();
|
||||
this.map = map;
|
||||
// Sort keys to start with the most specific
|
||||
this.sorted = new ArrayList<String>(map.keySet());
|
||||
this.sorted = new ArrayList<>(map.keySet());
|
||||
Collections.sort(this.sorted, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ public class PatternMatchingClassifier<T> implements Classifier<String, T> {
|
||||
* classifier, otherwise all inputs will cause an exception.
|
||||
*/
|
||||
public PatternMatchingClassifier() {
|
||||
this(new HashMap<String, T>());
|
||||
this(new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ public class PatternMatchingClassifier<T> implements Classifier<String, T> {
|
||||
*/
|
||||
public PatternMatchingClassifier(Map<String, T> values) {
|
||||
super();
|
||||
this.values = new PatternMatcher<T>(values);
|
||||
this.values = new PatternMatcher<>(values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ public class PatternMatchingClassifier<T> implements Classifier<String, T> {
|
||||
* @param values the pattern map to set
|
||||
*/
|
||||
public void setPatternMap(Map<String, T> values) {
|
||||
this.values = new PatternMatcher<T>(values);
|
||||
this.values = new PatternMatcher<>(values);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
@SuppressWarnings("serial")
|
||||
public class SubclassClassifier<T, C> implements Classifier<T, C> {
|
||||
|
||||
private ConcurrentMap<Class<? extends T>, C> classified = new ConcurrentHashMap<Class<? extends T>, C>();
|
||||
private ConcurrentMap<Class<? extends T>, C> classified = new ConcurrentHashMap<>();
|
||||
|
||||
private C defaultValue = null;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SubclassClassifier<T, C> implements Classifier<T, C> {
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
public SubclassClassifier(C defaultValue) {
|
||||
this(new HashMap<Class<? extends T>, C>(), defaultValue);
|
||||
this(new HashMap<>(), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ public class SubclassClassifier<T, C> implements Classifier<T, C> {
|
||||
*/
|
||||
public SubclassClassifier(Map<Class<? extends T>, C> typeMap, C defaultValue) {
|
||||
super();
|
||||
this.classified = new ConcurrentHashMap<Class<? extends T>, C>(typeMap);
|
||||
this.classified = new ConcurrentHashMap<>(typeMap);
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class SubclassClassifier<T, C> implements Classifier<T, C> {
|
||||
* @param map a map from type to class
|
||||
*/
|
||||
public void setTypeMap(Map<Class<? extends T>, C> map) {
|
||||
this.classified = new ConcurrentHashMap<Class<? extends T>, C>(map);
|
||||
this.classified = new ConcurrentHashMap<>(map);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,7 +79,7 @@ public class AnnotationMethodResolver implements MethodResolver {
|
||||
*/
|
||||
public Method findMethod(final Class<?> clazz) {
|
||||
Assert.notNull(clazz, "class must not be null");
|
||||
final AtomicReference<Method> annotatedMethod = new AtomicReference<Method>();
|
||||
final AtomicReference<Method> annotatedMethod = new AtomicReference<>();
|
||||
ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
|
||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||
Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -159,7 +159,7 @@ public class MethodInvokerUtils {
|
||||
// Proxy with no target cannot have annotations
|
||||
return null;
|
||||
}
|
||||
final AtomicReference<Method> annotatedMethod = new AtomicReference<Method>();
|
||||
final AtomicReference<Method> annotatedMethod = new AtomicReference<>();
|
||||
ReflectionUtils.doWithMethods(targetClass, new ReflectionUtils.MethodCallback() {
|
||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||
Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType);
|
||||
@@ -188,7 +188,7 @@ public class MethodInvokerUtils {
|
||||
* @param <C> the C
|
||||
*/
|
||||
public static <C, T> MethodInvoker getMethodInvokerForSingleArgument(Object target) {
|
||||
final AtomicReference<Method> methodHolder = new AtomicReference<Method>();
|
||||
final AtomicReference<Method> methodHolder = new AtomicReference<>();
|
||||
ReflectionUtils.doWithMethods(target.getClass(), new ReflectionUtils.MethodCallback() {
|
||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||
if ((method.getModifiers() & Modifier.PUBLIC) == 0 || method.isBridge()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -89,7 +89,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn
|
||||
|
||||
private final StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
|
||||
|
||||
private final ConcurrentReferenceHashMap<Object, ConcurrentMap<Method, MethodInterceptor>> delegates = new ConcurrentReferenceHashMap<Object, ConcurrentMap<Method, MethodInterceptor>>();
|
||||
private final ConcurrentReferenceHashMap<Object, ConcurrentMap<Method, MethodInterceptor>> delegates = new ConcurrentReferenceHashMap<>();
|
||||
|
||||
private RetryContextCache retryContextCache = new MapRetryContextCache();
|
||||
|
||||
@@ -137,7 +137,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn
|
||||
* @param globalListeners the default listeners
|
||||
*/
|
||||
public void setListeners(Collection<RetryListener> globalListeners) {
|
||||
ArrayList<RetryListener> retryListeners = new ArrayList<RetryListener>(globalListeners);
|
||||
ArrayList<RetryListener> retryListeners = new ArrayList<>(globalListeners);
|
||||
AnnotationAwareOrderComparator.sort(retryListeners);
|
||||
this.globalListeners = retryListeners.toArray(new RetryListener[0]);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn
|
||||
private MethodInterceptor getDelegate(Object target, Method method) {
|
||||
ConcurrentMap<Method, MethodInterceptor> cachedMethods = this.delegates.get(target);
|
||||
if (cachedMethods == null) {
|
||||
cachedMethods = new ConcurrentHashMap<Method, MethodInterceptor>();
|
||||
cachedMethods = new ConcurrentHashMap<>();
|
||||
}
|
||||
MethodInterceptor delegate = cachedMethods.get(method);
|
||||
if (delegate == null) {
|
||||
@@ -310,7 +310,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn
|
||||
if (!foundRecoverable.get()) {
|
||||
return null;
|
||||
}
|
||||
return new RecoverAnnotationRecoveryHandler<Object>(target, method);
|
||||
return new RecoverAnnotationRecoveryHandler<>(target, method);
|
||||
}
|
||||
|
||||
private RetryPolicy getRetryPolicy(Annotation retryable) {
|
||||
@@ -345,7 +345,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn
|
||||
simple.setMaxAttempts(maxAttempts);
|
||||
return simple;
|
||||
}
|
||||
Map<Class<? extends Throwable>, Boolean> policyMap = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> policyMap = new HashMap<>();
|
||||
for (Class<? extends Throwable> type : includes) {
|
||||
policyMap.put(type, true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,9 +56,9 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class RecoverAnnotationRecoveryHandler<T> implements MethodInvocationRecoverer<T> {
|
||||
|
||||
private final SubclassClassifier<Throwable, Method> classifier = new SubclassClassifier<Throwable, Method>();
|
||||
private final SubclassClassifier<Throwable, Method> classifier = new SubclassClassifier<>();
|
||||
|
||||
private final Map<Method, SimpleMetadata> methods = new HashMap<Method, SimpleMetadata>();
|
||||
private final Map<Method, SimpleMetadata> methods = new HashMap<>();
|
||||
|
||||
private final Object target;
|
||||
|
||||
@@ -197,7 +197,7 @@ public class RecoverAnnotationRecoveryHandler<T> implements MethodInvocationReco
|
||||
}
|
||||
|
||||
private void init(final Object target, Method method) {
|
||||
final Map<Class<? extends Throwable>, Method> types = new HashMap<Class<? extends Throwable>, Method>();
|
||||
final Map<Class<? extends Throwable>, Method> types = new HashMap<>();
|
||||
final Method failingMethod = method;
|
||||
Retryable retryable = AnnotationUtils.findAnnotation(method, Retryable.class);
|
||||
if (retryable != null) {
|
||||
@@ -284,7 +284,7 @@ public class RecoverAnnotationRecoveryHandler<T> implements MethodInvocationReco
|
||||
}
|
||||
|
||||
private void optionallyFilterMethodsBy(Class<?> returnClass) {
|
||||
Map<Method, SimpleMetadata> filteredMethods = new HashMap<Method, SimpleMetadata>();
|
||||
Map<Method, SimpleMetadata> filteredMethods = new HashMap<>();
|
||||
for (Method method : this.methods.keySet()) {
|
||||
if (method.getReturnType() == returnClass) {
|
||||
filteredMethods.put(method, this.methods.get(method));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -94,7 +94,7 @@ public class RetryConfiguration extends AbstractPointcutAdvisor
|
||||
this.newMethodArgumentsIdentifier = findBean(NewMethodArgumentsIdentifier.class);
|
||||
this.retryListeners = findBeans(RetryListener.class);
|
||||
this.sleeper = findBean(Sleeper.class);
|
||||
Set<Class<? extends Annotation>> retryableAnnotationTypes = new LinkedHashSet<Class<? extends Annotation>>(1);
|
||||
Set<Class<? extends Annotation>> retryableAnnotationTypes = new LinkedHashSet<>(1);
|
||||
retryableAnnotationTypes.add(Retryable.class);
|
||||
this.pointcut = buildPointcut(retryableAnnotationTypes);
|
||||
this.advice = buildAdvice();
|
||||
@@ -107,7 +107,7 @@ public class RetryConfiguration extends AbstractPointcutAdvisor
|
||||
if (this.beanFactory instanceof ListableBeanFactory) {
|
||||
ListableBeanFactory listable = (ListableBeanFactory) this.beanFactory;
|
||||
if (listable.getBeanNamesForType(type).length > 0) {
|
||||
ArrayList<T> list = new ArrayList<T>(listable.getBeansOfType(type, false, false).values());
|
||||
ArrayList<T> list = new ArrayList<>(listable.getBeansOfType(type, false, false).values());
|
||||
OrderComparator.sort(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -123,7 +123,7 @@ public class CompositeRetryPolicy implements RetryPolicy {
|
||||
*/
|
||||
@Override
|
||||
public RetryContext open(RetryContext parent) {
|
||||
List<RetryContext> list = new ArrayList<RetryContext>();
|
||||
List<RetryContext> list = new ArrayList<>();
|
||||
for (RetryPolicy policy : this.policies) {
|
||||
list.add(policy.open(parent));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,8 +37,7 @@ import org.springframework.util.Assert;
|
||||
@SuppressWarnings("serial")
|
||||
public class ExceptionClassifierRetryPolicy implements RetryPolicy {
|
||||
|
||||
private Classifier<Throwable, RetryPolicy> exceptionClassifier = new ClassifierSupport<Throwable, RetryPolicy>(
|
||||
new NeverRetryPolicy());
|
||||
private Classifier<Throwable, RetryPolicy> exceptionClassifier = new ClassifierSupport<>(new NeverRetryPolicy());
|
||||
|
||||
/**
|
||||
* Setter for policy map used to create a classifier. Either this property or the
|
||||
@@ -47,7 +46,7 @@ public class ExceptionClassifierRetryPolicy implements RetryPolicy {
|
||||
* to create a {@link Classifier} to locate a policy.
|
||||
*/
|
||||
public void setPolicyMap(Map<Class<? extends Throwable>, RetryPolicy> policyMap) {
|
||||
this.exceptionClassifier = new SubclassClassifier<Throwable, RetryPolicy>(policyMap, new NeverRetryPolicy());
|
||||
this.exceptionClassifier = new SubclassClassifier<>(policyMap, new NeverRetryPolicy());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +111,7 @@ public class ExceptionClassifierRetryPolicy implements RetryPolicy {
|
||||
// Dynamic: depends on the policy:
|
||||
private RetryContext context;
|
||||
|
||||
final private Map<RetryPolicy, RetryContext> contexts = new HashMap<RetryPolicy, RetryContext>();
|
||||
final private Map<RetryPolicy, RetryContext> contexts = new HashMap<>();
|
||||
|
||||
public ExceptionClassifierRetryContext(RetryContext parent,
|
||||
Classifier<Throwable, RetryPolicy> exceptionClassifier) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class MapRetryContextCache implements RetryContextCache {
|
||||
*/
|
||||
public static final int DEFAULT_CAPACITY = 4096;
|
||||
|
||||
private Map<Object, RetryContext> map = Collections.synchronizedMap(new HashMap<Object, RetryContext>());
|
||||
private Map<Object, RetryContext> map = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
private int capacity;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,7 @@ public class SoftReferenceMapRetryContextCache implements RetryContextCache {
|
||||
*/
|
||||
public static final int DEFAULT_CAPACITY = 4096;
|
||||
|
||||
private Map<Object, SoftReference<RetryContext>> map = Collections
|
||||
.synchronizedMap(new HashMap<Object, SoftReference<RetryContext>>());
|
||||
private Map<Object, SoftReference<RetryContext>> map = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
private int capacity;
|
||||
|
||||
@@ -91,7 +90,7 @@ public class SoftReferenceMapRetryContextCache implements RetryContextCache {
|
||||
+ "Do you need to re-consider the implementation of the key generator, "
|
||||
+ "or the equals and hashCode of the items that failed?");
|
||||
}
|
||||
map.put(key, new SoftReference<RetryContext>(context));
|
||||
map.put(key, new SoftReference<>(context));
|
||||
}
|
||||
|
||||
public void remove(Object key) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import org.springframework.retry.RetryStatistics;
|
||||
*/
|
||||
public class DefaultStatisticsRepository implements StatisticsRepository {
|
||||
|
||||
private ConcurrentMap<String, MutableRetryStatistics> map = new ConcurrentHashMap<String, MutableRetryStatistics>();
|
||||
private ConcurrentMap<String, MutableRetryStatistics> map = new ConcurrentHashMap<>();
|
||||
|
||||
private RetryStatisticsFactory factory = new DefaultRetryStatisticsFactory();
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DefaultStatisticsRepository implements StatisticsRepository {
|
||||
|
||||
@Override
|
||||
public Iterable<RetryStatistics> findAll() {
|
||||
return new ArrayList<RetryStatistics>(map.values());
|
||||
return new ArrayList<>(map.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,9 +25,9 @@ import java.util.List;
|
||||
*/
|
||||
public class RetrySimulation {
|
||||
|
||||
private final List<SleepSequence> sleepSequences = new ArrayList<SleepSequence>();
|
||||
private final List<SleepSequence> sleepSequences = new ArrayList<>();
|
||||
|
||||
private final List<Long> sleepHistogram = new ArrayList<Long>();
|
||||
private final List<Long> sleepHistogram = new ArrayList<>();
|
||||
|
||||
public RetrySimulation() {
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class RetrySimulation {
|
||||
* all simulations.
|
||||
*/
|
||||
public List<Double> getPercentiles() {
|
||||
List<Double> res = new ArrayList<Double>();
|
||||
List<Double> res = new ArrayList<>();
|
||||
for (double percentile : new double[] { 10, 20, 30, 40, 50, 60, 70, 80, 90 }) {
|
||||
res.add(getPercentile(percentile / 100));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -112,7 +112,7 @@ public class RetrySimulator {
|
||||
@SuppressWarnings("serial")
|
||||
static class StealingSleeper implements Sleeper {
|
||||
|
||||
private final List<Long> sleeps = new ArrayList<Long>();
|
||||
private final List<Long> sleeps = new ArrayList<>();
|
||||
|
||||
public void sleep(long backOffPeriod) throws InterruptedException {
|
||||
sleeps.add(backOffPeriod);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ public final class RetrySynchronizationManager {
|
||||
private RetrySynchronizationManager() {
|
||||
}
|
||||
|
||||
private static final ThreadLocal<RetryContext> context = new ThreadLocal<RetryContext>();
|
||||
private static final ThreadLocal<RetryContext> context = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Public accessor for the locally enclosing {@link RetryContext}.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -159,7 +159,7 @@ public class RetryTemplate implements RetryOperations {
|
||||
* @see #setListeners(RetryListener[])
|
||||
*/
|
||||
public void registerListener(RetryListener listener, int index) {
|
||||
List<RetryListener> list = new ArrayList<RetryListener>(Arrays.asList(this.listeners));
|
||||
List<RetryListener> list = new ArrayList<>(Arrays.asList(this.listeners));
|
||||
if (index >= list.size()) {
|
||||
list.add(listener);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -458,7 +458,7 @@ public class RetryTemplateBuilder {
|
||||
|
||||
private List<RetryListener> listenersList() {
|
||||
if (this.listeners == null) {
|
||||
this.listeners = new ArrayList<RetryListener>();
|
||||
this.listeners = new ArrayList<>();
|
||||
}
|
||||
return this.listeners;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,13 +31,13 @@ import org.springframework.classify.annotation.Classifier;
|
||||
*/
|
||||
public class BackToBackPatternClassifierTests {
|
||||
|
||||
private BackToBackPatternClassifier<String, String> classifier = new BackToBackPatternClassifier<String, String>();
|
||||
private BackToBackPatternClassifier<String, String> classifier = new BackToBackPatternClassifier<>();
|
||||
|
||||
private Map<String, String> map;
|
||||
|
||||
@Before
|
||||
public void createMap() {
|
||||
map = new HashMap<String, String>();
|
||||
map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
map.put("*", "spam");
|
||||
}
|
||||
@@ -49,9 +49,9 @@ public class BackToBackPatternClassifierTests {
|
||||
|
||||
@Test
|
||||
public void testCreateFromConstructor() {
|
||||
classifier = new BackToBackPatternClassifier<String, String>(
|
||||
new PatternMatchingClassifier<String>(Collections.singletonMap("oof", "bucket")),
|
||||
new PatternMatchingClassifier<String>(map));
|
||||
classifier = new BackToBackPatternClassifier<>(
|
||||
new PatternMatchingClassifier<>(Collections.singletonMap("oof", "bucket")),
|
||||
new PatternMatchingClassifier<>(map));
|
||||
assertEquals("spam", classifier.classify("oof"));
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class BackToBackPatternClassifierTests {
|
||||
|
||||
@Test
|
||||
public void testSingleMethodWithNoAnnotation() {
|
||||
classifier = new BackToBackPatternClassifier<String, String>();
|
||||
classifier = new BackToBackPatternClassifier<>();
|
||||
classifier.setRouterDelegate(new RouterDelegate());
|
||||
classifier.setMatcherMap(map);
|
||||
assertEquals("spam", classifier.classify("oof"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ public class BinaryExceptionClassifierTests {
|
||||
|
||||
@Test
|
||||
public void testClassifySubclassMatchInCauseFalse() {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
map.put(IllegalStateException.class, true);
|
||||
map.put(BarException.class, false);
|
||||
BinaryExceptionClassifier binaryExceptionClassifier = new BinaryExceptionClassifier(map, true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,11 +27,11 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public class ClassifierAdapterTests {
|
||||
|
||||
private ClassifierAdapter<String, Integer> adapter = new ClassifierAdapter<String, Integer>();
|
||||
private ClassifierAdapter<String, Integer> adapter = new ClassifierAdapter<>();
|
||||
|
||||
@Test
|
||||
public void testClassifierAdapterObject() {
|
||||
adapter = new ClassifierAdapter<String, Integer>(new Object() {
|
||||
adapter = new ClassifierAdapter<>(new Object() {
|
||||
@Classifier
|
||||
public Integer getValue(String key) {
|
||||
return Integer.parseInt(key);
|
||||
@@ -47,7 +47,7 @@ public class ClassifierAdapterTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testClassifierAdapterObjectWithNoAnnotation() {
|
||||
adapter = new ClassifierAdapter<String, Integer>(new Object() {
|
||||
adapter = new ClassifierAdapter<>(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
public Integer getValue(String key) {
|
||||
return Integer.parseInt(key);
|
||||
@@ -63,7 +63,7 @@ public class ClassifierAdapterTests {
|
||||
|
||||
@Test
|
||||
public void testClassifierAdapterObjectSingleMethodWithNoAnnotation() {
|
||||
adapter = new ClassifierAdapter<String, Integer>(new Object() {
|
||||
adapter = new ClassifierAdapter<>(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
public Integer getValue(String key) {
|
||||
return Integer.parseInt(key);
|
||||
@@ -84,12 +84,11 @@ public class ClassifierAdapterTests {
|
||||
@SuppressWarnings({ "serial" })
|
||||
@Test
|
||||
public void testClassifierAdapterClassifier() {
|
||||
adapter = new ClassifierAdapter<String, Integer>(
|
||||
new org.springframework.classify.Classifier<String, Integer>() {
|
||||
public Integer classify(String classifiable) {
|
||||
return Integer.valueOf(classifiable);
|
||||
}
|
||||
});
|
||||
adapter = new ClassifierAdapter<>(new org.springframework.classify.Classifier<String, Integer>() {
|
||||
public Integer classify(String classifiable) {
|
||||
return Integer.valueOf(classifiable);
|
||||
}
|
||||
});
|
||||
assertEquals(23, adapter.classify("23").intValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,13 +24,13 @@ public class ClassifierSupportTests {
|
||||
|
||||
@Test
|
||||
public void testClassifyNullIsDefault() {
|
||||
ClassifierSupport<String, String> classifier = new ClassifierSupport<String, String>("foo");
|
||||
ClassifierSupport<String, String> classifier = new ClassifierSupport<>("foo");
|
||||
assertEquals(classifier.classify(null), "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassifyRandomException() {
|
||||
ClassifierSupport<Throwable, String> classifier = new ClassifierSupport<Throwable, String>("foo");
|
||||
ClassifierSupport<Throwable, String> classifier = new ClassifierSupport<>("foo");
|
||||
assertEquals(classifier.classify(new IllegalStateException("Foo")), classifier.classify(null));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,13 +30,13 @@ import org.springframework.classify.PatternMatchingClassifier;
|
||||
*/
|
||||
public class PatternMatchingClassifierTests {
|
||||
|
||||
private PatternMatchingClassifier<String> classifier = new PatternMatchingClassifier<String>();
|
||||
private PatternMatchingClassifier<String> classifier = new PatternMatchingClassifier<>();
|
||||
|
||||
private Map<String, String> map;
|
||||
|
||||
@Before
|
||||
public void createMap() {
|
||||
map = new HashMap<String, String>();
|
||||
map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
map.put("*", "spam");
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class PatternMatchingClassifierTests {
|
||||
|
||||
@Test
|
||||
public void testCreateFromMap() {
|
||||
classifier = new PatternMatchingClassifier<String>(map);
|
||||
classifier = new PatternMatchingClassifier<>(map);
|
||||
assertEquals("bar", classifier.classify("foo"));
|
||||
assertEquals("spam", classifier.classify("bucket"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,14 +27,14 @@ public class SubclassClassifierTests {
|
||||
|
||||
@Test
|
||||
public void testClassifyInterface() {
|
||||
SubclassClassifier<Object, String> classifier = new SubclassClassifier<Object, String>();
|
||||
SubclassClassifier<Object, String> classifier = new SubclassClassifier<>();
|
||||
classifier.setTypeMap(Collections.<Class<?>, String>singletonMap(Supplier.class, "foo"));
|
||||
assertEquals("foo", classifier.classify(new Foo()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassifyInterfaceOfParent() {
|
||||
SubclassClassifier<Object, String> classifier = new SubclassClassifier<Object, String>();
|
||||
SubclassClassifier<Object, String> classifier = new SubclassClassifier<>();
|
||||
classifier.setTypeMap(Collections.<Class<?>, String>singletonMap(Supplier.class, "foo"));
|
||||
assertEquals("foo", classifier.classify(new Bar()));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ import static org.junit.Assert.assertNull;
|
||||
|
||||
public class SubclassExceptionClassifierTests {
|
||||
|
||||
SubclassClassifier<Throwable, String> classifier = new SubclassClassifier<Throwable, String>();
|
||||
SubclassClassifier<Throwable, String> classifier = new SubclassClassifier<>();
|
||||
|
||||
@Test
|
||||
public void testClassifyNullIsDefault() {
|
||||
@@ -44,7 +44,7 @@ public class SubclassExceptionClassifierTests {
|
||||
|
||||
@Test
|
||||
public void testClassifyNullNonDefault() {
|
||||
this.classifier = new SubclassClassifier<Throwable, String>("foo");
|
||||
this.classifier = new SubclassClassifier<>("foo");
|
||||
assertEquals("foo", this.classifier.classify(null));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SubclassExceptionClassifierTests {
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testClassifyAncestorMatch2() {
|
||||
this.classifier = new SubclassClassifier<Throwable, String>();
|
||||
this.classifier = new SubclassClassifier<>();
|
||||
this.classifier.setTypeMap(new HashMap<Class<? extends Throwable>, String>() {
|
||||
{
|
||||
put(SocketException.class, "1");
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.retry;
|
||||
|
||||
import java.util.Stack;
|
||||
@@ -23,7 +39,7 @@ public class ResourcelessTransactionManager extends AbstractPlatformTransactionM
|
||||
Object transaction = new ResourcelessTransaction();
|
||||
Stack<Object> resources;
|
||||
if (!TransactionSynchronizationManager.hasResource(this)) {
|
||||
resources = new Stack<Object>();
|
||||
resources = new Stack<>();
|
||||
TransactionSynchronizationManager.bindResource(this, resources);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -133,7 +133,7 @@ public class EnableRetryWithBackoffTests {
|
||||
@SuppressWarnings("serial")
|
||||
protected static class PeriodSleeper implements Sleeper {
|
||||
|
||||
private List<Long> periods = new ArrayList<Long>();
|
||||
private List<Long> periods = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void sleep(long period) throws InterruptedException {
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ProxyApplicationTests {
|
||||
|
||||
private static class CountClassesClassLoader extends URLClassLoader {
|
||||
|
||||
private final Set<Class<?>> classes = new HashSet<Class<?>>();
|
||||
private final Set<Class<?>> classes = new HashSet<>();
|
||||
|
||||
public CountClassesClassLoader() {
|
||||
super(new URL[0], ProxyApplicationTests.class.getClassLoader());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,7 +52,7 @@ public class BackOffPolicySerializationTests {
|
||||
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> policies() {
|
||||
List<Object[]> result = new ArrayList<Object[]>();
|
||||
List<Object[]> result = new ArrayList<>();
|
||||
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
|
||||
scanner.addIncludeFilter(new AssignableTypeFilter(BackOffPolicy.class));
|
||||
scanner.addExcludeFilter(new RegexPatternTypeFilter(Pattern.compile(".*Test.*")));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
@SuppressWarnings("serial")
|
||||
public class DummySleeper implements Sleeper {
|
||||
|
||||
private List<Long> backOffs = new ArrayList<Long>();
|
||||
private List<Long> backOffs = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Public getter for the long.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -128,7 +128,7 @@ public class RetryOperationsInterceptorTests {
|
||||
final String classTagName = "class";
|
||||
final String methodTagName = "method";
|
||||
final String labelTagName = "label";
|
||||
final Map<String, String> monitoringTags = new HashMap<String, String>();
|
||||
final Map<String, String> monitoringTags = new HashMap<>();
|
||||
RetryTemplate template = new RetryTemplate();
|
||||
template.setRetryPolicy(new SimpleRetryPolicy(2));
|
||||
template.registerListener(new MethodInvocationRetryListenerSupport() {
|
||||
@@ -174,7 +174,7 @@ public class RetryOperationsInterceptorTests {
|
||||
@Test
|
||||
public void testInterceptorChainWithRetry() throws Exception {
|
||||
((Advised) this.service).addAdvice(this.interceptor);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
((Advised) this.service).addAdvice(new MethodInterceptor() {
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
|
||||
@@ -149,7 +149,7 @@ public class StatefulRetryOperationsInterceptorTests {
|
||||
@Test
|
||||
public void testInterceptorChainWithRetry() throws Exception {
|
||||
((Advised) service).addAdvice(interceptor);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
((Advised) service).addAdvice(new MethodInterceptor() {
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ public class RetryListenerTests {
|
||||
|
||||
int count = 0;
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
@Test
|
||||
public void testOpenInterceptors() throws Throwable {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -89,7 +89,7 @@ public class CompositeRetryPolicyTests {
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testNonTrivialPoliciesClose() throws Exception {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
|
||||
public void close(RetryContext context) {
|
||||
@@ -109,7 +109,7 @@ public class CompositeRetryPolicyTests {
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testExceptionOnPoliciesClose() throws Exception {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
|
||||
public void close(RetryContext context) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,7 +52,7 @@ public class ExceptionClassifierRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
public void testNullPolicies() throws Exception {
|
||||
policy.setPolicyMap(new HashMap<Class<? extends Throwable>, RetryPolicy>());
|
||||
policy.setPolicyMap(new HashMap<>());
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ public class FatalExceptionRetryPolicyTests {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
|
||||
// Make sure certain exceptions are fatal...
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
map.put(IllegalArgumentException.class, false);
|
||||
map.put(IllegalStateException.class, false);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class FatalExceptionRetryPolicyTests {
|
||||
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
map.put(IllegalArgumentException.class, false);
|
||||
map.put(IllegalStateException.class, false);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,7 +55,7 @@ public class RetryContextSerializationTests {
|
||||
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> policies() {
|
||||
List<Object[]> result = new ArrayList<Object[]>();
|
||||
List<Object[]> result = new ArrayList<>();
|
||||
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
|
||||
scanner.addIncludeFilter(new AssignableTypeFilter(RetryPolicy.class));
|
||||
scanner.addExcludeFilter(new RegexPatternTypeFilter(Pattern.compile(".*Test.*")));
|
||||
@@ -71,7 +71,7 @@ public class RetryContextSerializationTests {
|
||||
}
|
||||
}
|
||||
ExceptionClassifierRetryPolicy extra = new ExceptionClassifierRetryPolicy();
|
||||
extra.setExceptionClassifier(new SubclassClassifier<Throwable, RetryPolicy>(new AlwaysRetryPolicy()));
|
||||
extra.setExceptionClassifier(new SubclassClassifier<>(new AlwaysRetryPolicy()));
|
||||
result.add(new Object[] { extra });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ public class SerializedMapRetryContextCache implements RetryContextCache {
|
||||
|
||||
private static final int DEFAULT_CAPACITY = 4096;
|
||||
|
||||
private Map<Object, byte[]> map = Collections.synchronizedMap(new HashMap<Object, byte[]>());
|
||||
private Map<Object, byte[]> map = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -107,7 +107,7 @@ public class SimpleRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
public void testFatalOverridesRetryable() throws Exception {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
map.put(Exception.class, false);
|
||||
map.put(RuntimeException.class, true);
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map);
|
||||
@@ -119,7 +119,7 @@ public class SimpleRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
public void testRetryableWithCause() throws Exception {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
map.put(RuntimeException.class, true);
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map, true);
|
||||
RetryContext context = policy.open(null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2012 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -158,7 +158,7 @@ public class StatefulRetryIntegrationTests {
|
||||
policy.setMultiplier(1.5);
|
||||
RetryTemplate template = new RetryTemplate();
|
||||
template.setBackOffPolicy(policy);
|
||||
final List<Long> times = new ArrayList<Long>();
|
||||
final List<Long> times = new ArrayList<>();
|
||||
RetryState retryState = new DefaultRetryState("bar");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,7 +47,7 @@ public class StatefulRecoveryRetryTests {
|
||||
|
||||
private int count = 0;
|
||||
|
||||
private List<String> list = new ArrayList<String>();
|
||||
private List<String> list = new ArrayList<>();
|
||||
|
||||
@Test
|
||||
public void testOpenSunnyDay() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user