From 532f323313f1b7cfd9163cf5d60f891cbcbacb40 Mon Sep 17 00:00:00 2001 From: abilan Date: Mon, 28 Nov 2022 15:49:52 -0500 Subject: [PATCH] Move Spring dependencies to SNAPSHOTs * Use a `DefaultParameterNameDiscoverer` instead of deprecated `LocalVariableTableParameterNameDiscoverer` * Fix assertion error message for `@Header` without `name` and with no `-parameters` compiler flag. * Remove redundant repos for Gradle plugins Related to: https://stackoverflow.com/questions/74600681/warning-printed-after-migrating-to-spring-boot-3-0-spring-integration-6-0 --- build.gradle | 22 +++++++------------ .../aop/MessagePublishingInterceptor.java | 6 ++--- ...thodAnnotationPublisherMetadataSource.java | 6 ++--- .../GatewayMethodInboundMessageMapper.java | 9 ++++---- .../support/MessagingMethodInvokerHelper.java | 9 ++++---- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index f062bfac75..8c997b5590 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,7 @@ buildscript { ext.kotlinVersion = '1.7.21' ext.isCI = System.getenv('GITHUB_ACTION') || System.getenv('bamboo_buildKey') repositories { - mavenCentral() gradlePluginPortal() - jcenter() { - content { - includeGroup('com.burgstaller') - } - } maven { url 'https://repo.spring.io/plugins-release' } if (version.endsWith('SNAPSHOT')) { maven { url 'https://repo.spring.io/snapshot' } @@ -107,14 +101,14 @@ ext { rsocketVersion = '1.1.3' servletApiVersion = '6.0.0' smackVersion = '4.4.6' - springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '3.0.0' - springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2022.0.0' - springGraphqlVersion = '1.1.0' - springKafkaVersion = '3.0.0' - springRetryVersion = '2.0.0' - springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '6.0.0' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '6.0.0' - springWsVersion = '4.0.0' + springAmqpVersion = '3.0.1-SNAPSHOT' + springDataVersion = '2022.0.1-SNAPSHOT' + springGraphqlVersion = '1.1.1-SNAPSHOT' + springKafkaVersion = '3.0.1-SNAPSHOT' + springRetryVersion = '2.0.1-SNAPSHOT' + springSecurityVersion = '6.0.1-SNAPSHOT' + springVersion = '6.0.3-SNAPSHOT' + springWsVersion = '4.0.1-SNAPSHOT' testcontainersVersion = '1.17.6' tomcatVersion = '10.1.1' xmlUnitVersion = '2.9.0' diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java index 1c61c845a6..b892bcff8a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java @@ -27,7 +27,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; +import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.ParameterNameDiscoverer; import org.springframework.expression.Expression; import org.springframework.expression.spel.support.StandardEvaluationContext; @@ -60,7 +60,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact private final MessagingTemplate messagingTemplate = new MessagingTemplate(); - private final ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer(); + private final ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer(); private final PublisherMetadataSource metadataSource; @@ -113,7 +113,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact initMessagingTemplateIfAny(); StandardEvaluationContext context = ExpressionUtils.createStandardEvaluationContext(this.beanFactory); Class targetClass = AopUtils.getTargetClass(invocation.getThis()); - final Method method = AopUtils.getMostSpecificMethod(invocation.getMethod(), targetClass); + Method method = AopUtils.getMostSpecificMethod(invocation.getMethod(), targetClass); String[] argumentNames = resolveArgumentNames(method); context.setVariable(PublisherMetadataSource.METHOD_NAME_VARIABLE_NAME, method.getName()); if (invocation.getArguments().length > 0 && argumentNames != null) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java index b9373c2108..297096ad73 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-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,7 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; +import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.ParameterNameDiscoverer; import org.springframework.core.annotation.MergedAnnotation; import org.springframework.core.annotation.MergedAnnotations; @@ -52,7 +52,7 @@ import org.springframework.util.StringUtils; */ public class MethodAnnotationPublisherMetadataSource implements PublisherMetadataSource { - private final ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer(); + private final ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer(); private final Map channels = new ConcurrentHashMap<>(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java index aa1d80b6e1..c522c6281b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java @@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; +import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.core.ParameterNameDiscoverer; import org.springframework.core.annotation.AnnotationUtils; @@ -89,6 +89,8 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper parameterPayloadExpressions = new HashMap<>(); private final Method method; @@ -242,17 +244,16 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper getMethodParameterList(Method method) { List parameterList = new LinkedList<>(); - ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer(); for (int i = 0; i < method.getParameterCount(); i++) { MethodParameter methodParameter = new SynthesizingMethodParameter(method, i); - methodParameter.initParameterNameDiscovery(parameterNameDiscoverer); + methodParameter.initParameterNameDiscovery(PARAMETER_NAME_DISCOVERER); parameterList.add(methodParameter); } return parameterList; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java index 7628d1961b..f2b2453ce0 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java @@ -49,8 +49,8 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.Lifecycle; import org.springframework.context.expression.StandardBeanExpressionResolver; +import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.KotlinDetector; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.core.ParameterNameDiscoverer; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -143,8 +143,7 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator im private static final ExpressionParser EXPRESSION_PARSER_MIXED = new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.MIXED, null)); - private static final ParameterNameDiscoverer PARAMETER_NAME_DISCOVERER = - new LocalVariableTableParameterNameDiscoverer(); + private static final ParameterNameDiscoverer PARAMETER_NAME_DISCOVERER = new DefaultParameterNameDiscoverer(); private static final Map SPEL_COMPILERS = new HashMap<>(); @@ -1285,8 +1284,8 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator im } } - Assert.notNull(headerName, "Cannot determine header name. Possible reasons: -debug is " - + "disabled or header name is not explicitly provided via @Header annotation."); + Assert.notNull(headerName, "Cannot determine header name. Possible reasons: the -parameters compiler flag " + + "is disabled or header name is not explicitly provided via @Header annotation."); String headerRetrievalExpression = "headers['" + headerName + "']"; String fullHeaderExpression = headerRetrievalExpression + relativeExpression; if (annotationAttributes.getBoolean("required")