Skip to content

Commit f12248f

Browse files
committed
ClassUtils: deprecate methods with typos
The `ClassUtils.isKotlinFaction0()` and `ClassUtils.isKotlinFaction1()` are wrong names. * Deprecate `ClassUtils.isKotlinFaction0()` and `ClassUtils.isKotlinFaction1()` in favor of newly introduced `isKotlinFunction0()` and `isKotlinFunction1()` **Cherry-pick to `main`**
1 parent e0f1379 commit f12248f

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,6 @@ private MessageHandler registerHandlerBean(String beanName, Method method, final
197197
return this.beanFactory.getBean(handlerBeanName, MessageHandler.class);
198198
}
199199

200-
private void orderable(Method method, MessageHandler handler) {
201-
if (handler instanceof Orderable) {
202-
Order orderAnnotation = AnnotationUtils.findAnnotation(method, Order.class);
203-
if (orderAnnotation != null) {
204-
((Orderable) handler).setOrder(orderAnnotation.value());
205-
}
206-
}
207-
}
208-
209200
private void producerOrRouter(List<Annotation> annotations, MessageHandler handler) {
210201
if (handler instanceof AbstractMessageProducingHandler || handler instanceof AbstractMessageRouter) {
211202
String sendTimeout = MessagingAnnotationUtils.resolveAttribute(annotations, "sendTimeout", String.class);
@@ -608,7 +599,7 @@ protected boolean resolveAttributeToBoolean(String attribute) {
608599
@Nullable
609600
protected MessageProcessor<?> buildLambdaMessageProcessorForBeanMethod(Method method, Object target) {
610601
if ((target instanceof Function || target instanceof Consumer) && ClassUtils.isLambda(target.getClass())
611-
|| ClassUtils.isKotlinFaction1(target.getClass())) {
602+
|| ClassUtils.isKotlinFunction1(target.getClass())) {
612603

613604
ResolvableType methodReturnType = ResolvableType.forMethodReturnType(method);
614605
Class<?> expectedPayloadType = methodReturnType.getGeneric(0).toClass();
@@ -619,6 +610,15 @@ protected MessageProcessor<?> buildLambdaMessageProcessorForBeanMethod(Method me
619610
}
620611
}
621612

613+
private static void orderable(Method method, MessageHandler handler) {
614+
if (handler instanceof Orderable) {
615+
Order orderAnnotation = AnnotationUtils.findAnnotation(method, Order.class);
616+
if (orderAnnotation != null) {
617+
((Orderable) handler).setOrder(orderAnnotation.value());
618+
}
619+
}
620+
}
621+
622622
/**
623623
* Subclasses must implement this method to create the MessageHandler.
624624
* @param bean The bean.

spring-integration-core/src/main/java/org/springframework/integration/config/annotation/InboundChannelAdapterAnnotationPostProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ private MessageSource<?> createMessageSource(Object beanArg, String beanNameArg,
9999
Class<?> targetClass = target.getClass();
100100
Assert.isTrue(MessageSource.class.isAssignableFrom(targetClass) ||
101101
Supplier.class.isAssignableFrom(targetClass) ||
102-
ClassUtils.isKotlinFaction0(targetClass),
102+
ClassUtils.isKotlinFunction0(targetClass),
103103
() -> "The '" + this.annotationType + "' on @Bean method " + "level is allowed only for: " +
104-
MessageSource.class.getName() + " or " + Supplier.class.getName() +
104+
MessageSource.class.getName() + ", or " + Supplier.class.getName() +
105105
(ClassUtils.KOTLIN_FUNCTION_0_CLASS != null
106-
? " or " + ClassUtils.KOTLIN_FUNCTION_0_CLASS.getName()
106+
? ", or " + ClassUtils.KOTLIN_FUNCTION_0_CLASS.getName()
107107
: "") + " beans");
108108
if (target instanceof MessageSource<?>) {
109109
messageSource = (MessageSource<?>) target;

spring-integration-core/src/main/java/org/springframework/integration/util/ClassUtils.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -250,21 +250,46 @@ public static boolean isLambda(Class<?> aClass) {
250250
* @param aClass the {@link Class} to check.
251251
* @return true if class is a {@code kotlin.jvm.functions.Function0} implementation.
252252
* @since 5.2
253+
* @deprecated since 5.5.14 in favor of {@link #isKotlinFunction0(Class)}
253254
*/
255+
@Deprecated
254256
public static boolean isKotlinFaction0(Class<?> aClass) {
255257
return KOTLIN_FUNCTION_0_CLASS != null && KOTLIN_FUNCTION_0_CLASS.isAssignableFrom(aClass);
256258
}
257259

260+
/**
261+
* Check if class is {@code kotlin.jvm.functions.Function0}.
262+
* @param aClass the {@link Class} to check.
263+
* @return true if class is a {@code kotlin.jvm.functions.Function0} implementation.
264+
* @since 5.5.14
265+
*/
266+
public static boolean isKotlinFunction0(Class<?> aClass) {
267+
return KOTLIN_FUNCTION_0_CLASS != null && KOTLIN_FUNCTION_0_CLASS.isAssignableFrom(aClass);
268+
}
269+
258270
/**
259271
* Check if class is {@code kotlin.jvm.functions.Function1}.
260272
* @param aClass the {@link Class} to check.
261273
* @return true if class is a {@code kotlin.jvm.functions.Function1} implementation.
262274
* @since 5.2
275+
* @deprecated since 5.5.14 in favor of {@link #isKotlinFunction1(Class)}
263276
*/
277+
@Deprecated
264278
public static boolean isKotlinFaction1(Class<?> aClass) {
265279
return KOTLIN_FUNCTION_1_CLASS != null && KOTLIN_FUNCTION_1_CLASS.isAssignableFrom(aClass);
266280
}
267281

282+
/**
283+
* Check if class is {@code kotlin.jvm.functions.Function1}.
284+
* @param aClass the {@link Class} to check.
285+
* @return true if class is a {@code kotlin.jvm.functions.Function1} implementation.
286+
* @since 5.5.14
287+
*/
288+
public static boolean isKotlinFunction1(Class<?> aClass) {
289+
return KOTLIN_FUNCTION_1_CLASS != null && KOTLIN_FUNCTION_1_CLASS.isAssignableFrom(aClass);
290+
}
291+
292+
268293
/**
269294
* Check if class is {@code kotlin.Unit}.
270295
* @param aClass the {@link Class} to check.

0 commit comments

Comments
 (0)