Merge pull request #286 from garyrussell

* pr/286:
  Polish contribution
  Switch to Java 17 on CI
  JDK17; Spring Framework 6.0.0-SNAPSHOT

Closes gh-286
This commit is contained in:
Stephane Nicoll
2022-04-19 08:32:31 +02:00
4 changed files with 18 additions and 13 deletions

View File

@@ -2,7 +2,7 @@ FROM ubuntu:focal-20220404
ADD setup.sh /setup.sh
ADD get-jdk-url.sh /get-jdk-url.sh
RUN ./setup.sh java8
RUN ./setup.sh java17
ENV JAVA_HOME /opt/openjdk
ENV PATH $JAVA_HOME/bin:$PATH

View File

@@ -2,8 +2,8 @@
set -e
case "$1" in
java8)
echo "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u322-b06/OpenJDK8U-jdk_x64_linux_hotspot_8u322b06.tar.gz"
java17)
echo "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.2_8.tar.gz"
;;
*)
echo $"Unknown java version"

View File

@@ -28,12 +28,12 @@
<properties>
<revision>2.0.0-SNAPSHOT</revision>
<disable.checks>false</disable.checks>
<java.version>1.8</java.version>
<java.version>17</java.version>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring.framework.version>4.3.29.RELEASE</spring.framework.version>
<spring.framework.version>6.0.0-SNAPSHOT</spring.framework.version>
</properties>
<profiles>

View File

@@ -39,6 +39,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.core.OrderComparator;
@@ -51,7 +52,6 @@ import org.springframework.retry.policy.RetryContextCache;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.ReflectionUtils.MethodCallback;
/**
* Basic configuration for <code>@Retryable</code> processing. For stateful retry, if
@@ -62,6 +62,7 @@ import org.springframework.util.ReflectionUtils.MethodCallback;
* @author Dave Syer
* @author Artem Bilan
* @author Markus Heiden
* @author Gary Russell
* @since 1.1
*
*/
@@ -69,9 +70,9 @@ import org.springframework.util.ReflectionUtils.MethodCallback;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Component
public class RetryConfiguration extends AbstractPointcutAdvisor
implements IntroductionAdvisor, BeanFactoryAware, InitializingBean {
implements IntroductionAdvisor, BeanFactoryAware, InitializingBean, SmartInitializingSingleton {
private Advice advice;
private AnnotationAwareRetryOperationsInterceptor advice;
private Pointcut pointcut;
@@ -92,7 +93,6 @@ public class RetryConfiguration extends AbstractPointcutAdvisor
this.retryContextCache = findBean(RetryContextCache.class);
this.methodArgumentsKeyGenerator = findBean(MethodArgumentsKeyGenerator.class);
this.newMethodArgumentsIdentifier = findBean(NewMethodArgumentsIdentifier.class);
this.retryListeners = findBeans(RetryListener.class);
this.sleeper = findBean(Sleeper.class);
Set<Class<? extends Annotation>> retryableAnnotationTypes = new LinkedHashSet<>(1);
retryableAnnotationTypes.add(Retryable.class);
@@ -103,6 +103,14 @@ public class RetryConfiguration extends AbstractPointcutAdvisor
}
}
@Override
public void afterSingletonsInstantiated() {
this.retryListeners = findBeans(RetryListener.class);
if (this.retryListeners != null) {
this.advice.setListeners(this.retryListeners);
}
}
private <T> List<T> findBeans(Class<? extends T> type) {
if (this.beanFactory instanceof ListableBeanFactory) {
ListableBeanFactory listable = (ListableBeanFactory) this.beanFactory;
@@ -157,14 +165,11 @@ public class RetryConfiguration extends AbstractPointcutAdvisor
return this.pointcut;
}
protected Advice buildAdvice() {
protected AnnotationAwareRetryOperationsInterceptor buildAdvice() {
AnnotationAwareRetryOperationsInterceptor interceptor = new AnnotationAwareRetryOperationsInterceptor();
if (this.retryContextCache != null) {
interceptor.setRetryContextCache(this.retryContextCache);
}
if (this.retryListeners != null) {
interceptor.setListeners(this.retryListeners);
}
if (this.methodArgumentsKeyGenerator != null) {
interceptor.setKeyGenerator(this.methodArgumentsKeyGenerator);
}