Merge 2.2.x to 2022.

fix conflict and checkstyle
pull/2400/head
Freeman Lau 3 years ago
parent 22008adf25
commit 1a7f900a9c

@ -39,7 +39,6 @@ import org.springframework.cloud.stream.provisioning.ConsumerDestination;
import org.springframework.cloud.stream.provisioning.ProducerDestination; import org.springframework.cloud.stream.provisioning.ProducerDestination;
import org.springframework.integration.StaticMessageHeaderAccessor; import org.springframework.integration.StaticMessageHeaderAccessor;
import org.springframework.integration.acks.AcknowledgmentCallback; import org.springframework.integration.acks.AcknowledgmentCallback;
import org.springframework.integration.acks.AcknowledgmentCallback.Status;
import org.springframework.integration.channel.AbstractMessageChannel; import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.core.MessageProducer; import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.support.DefaultErrorMessageStrategy; import org.springframework.integration.support.DefaultErrorMessageStrategy;
@ -47,7 +46,6 @@ import org.springframework.integration.support.ErrorMessageStrategy;
import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException; import org.springframework.messaging.MessagingException;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -116,7 +114,7 @@ public class RocketMQMessageChannelBinder extends
ExtendedConsumerProperties<RocketMQConsumerProperties> extendedConsumerProperties) ExtendedConsumerProperties<RocketMQConsumerProperties> extendedConsumerProperties)
throws Exception { throws Exception {
// todo support anymous consumer // todo support anymous consumer
if (StringUtils.isEmpty(group)) { if (!StringUtils.hasLength(group)) {
throw new RuntimeException( throw new RuntimeException(
"'group must be configured for channel " + destination.getName()); "'group must be configured for channel " + destination.getName());
} }

@ -62,7 +62,7 @@ public final class RocketMQBeanContainerCache {
} }
public static <T> T getBean(String beanName, Class<T> clazz, T defaultObj) { public static <T> T getBean(String beanName, Class<T> clazz, T defaultObj) {
if (StringUtils.isEmpty(beanName)) { if (!StringUtils.hasLength(beanName)) {
return defaultObj; return defaultObj;
} }
Object obj = BEANS_CACHE.get(beanName); Object obj = BEANS_CACHE.get(beanName);

@ -60,8 +60,8 @@ public final class RocketMQConsumerFactory {
AllocateMessageQueueStrategy.class, AllocateMessageQueueStrategy.class,
new AllocateMessageQueueAveragely()); new AllocateMessageQueueAveragely());
RPCHook rpcHook = null; RPCHook rpcHook = null;
if (!StringUtils.isEmpty(consumerProperties.getAccessKey()) if (StringUtils.hasLength(consumerProperties.getAccessKey())
&& !StringUtils.isEmpty(consumerProperties.getSecretKey())) { && StringUtils.hasLength(consumerProperties.getSecretKey())) {
rpcHook = new AclClientRPCHook( rpcHook = new AclClientRPCHook(
new SessionCredentials(consumerProperties.getAccessKey(), new SessionCredentials(consumerProperties.getAccessKey(),
consumerProperties.getSecretKey())); consumerProperties.getSecretKey()));
@ -111,8 +111,8 @@ public final class RocketMQConsumerFactory {
AllocateMessageQueueStrategy.class); AllocateMessageQueueStrategy.class);
RPCHook rpcHook = null; RPCHook rpcHook = null;
if (!StringUtils.isEmpty(consumerProperties.getAccessKey()) if (StringUtils.hasLength(consumerProperties.getAccessKey())
&& !StringUtils.isEmpty(consumerProperties.getSecretKey())) { && StringUtils.hasLength(consumerProperties.getSecretKey())) {
rpcHook = new AclClientRPCHook( rpcHook = new AclClientRPCHook(
new SessionCredentials(consumerProperties.getAccessKey(), new SessionCredentials(consumerProperties.getAccessKey(),
consumerProperties.getSecretKey())); consumerProperties.getSecretKey()));

@ -65,8 +65,8 @@ public final class RocketMQProduceFactory {
"Property 'nameServer' is required"); "Property 'nameServer' is required");
RPCHook rpcHook = null; RPCHook rpcHook = null;
if (!StringUtils.isEmpty(producerProperties.getAccessKey()) if (StringUtils.hasLength(producerProperties.getAccessKey())
&& !StringUtils.isEmpty(producerProperties.getSecretKey())) { && StringUtils.hasLength(producerProperties.getSecretKey())) {
rpcHook = new AclClientRPCHook( rpcHook = new AclClientRPCHook(
new SessionCredentials(producerProperties.getAccessKey(), new SessionCredentials(producerProperties.getAccessKey(),
producerProperties.getSecretKey())); producerProperties.getSecretKey()));

@ -138,13 +138,13 @@ public final class RocketMQMessageConverterSupport {
if (Objects.nonNull(headers) && !headers.isEmpty()) { if (Objects.nonNull(headers) && !headers.isEmpty()) {
Object tag = headers.getOrDefault(Headers.TAGS, Object tag = headers.getOrDefault(Headers.TAGS,
headers.get(toRocketHeaderKey(Headers.TAGS))); headers.get(toRocketHeaderKey(Headers.TAGS)));
if (!StringUtils.isEmpty(tag)) { if (StringUtils.hasLength(tag.toString())) {
rocketMsg.setTags(String.valueOf(tag)); rocketMsg.setTags(String.valueOf(tag));
} }
Object keys = headers.getOrDefault(Headers.KEYS, Object keys = headers.getOrDefault(Headers.KEYS,
headers.get(toRocketHeaderKey(Headers.KEYS))); headers.get(toRocketHeaderKey(Headers.KEYS)));
if (!StringUtils.isEmpty(keys)) { if (StringUtils.hasLength(keys.toString())) {
rocketMsg.setKeys(keys.toString()); rocketMsg.setKeys(keys.toString());
} }
Object flagObj = headers.getOrDefault(Headers.FLAG, Object flagObj = headers.getOrDefault(Headers.FLAG,

@ -19,13 +19,13 @@ package com.alibaba.cloud.stream.binder.rocketmq.utils;
import com.alibaba.cloud.stream.binder.rocketmq.constant.RocketMQConst; import com.alibaba.cloud.stream.binder.rocketmq.constant.RocketMQConst;
import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQBinderConfigurationProperties; import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQBinderConfigurationProperties;
import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQCommonProperties; import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQCommonProperties;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.common.AclClientRPCHook; import org.apache.rocketmq.acl.common.AclClientRPCHook;
import org.apache.rocketmq.acl.common.SessionCredentials; import org.apache.rocketmq.acl.common.SessionCredentials;
import org.apache.rocketmq.client.consumer.MessageSelector; import org.apache.rocketmq.client.consumer.MessageSelector;
import org.apache.rocketmq.common.UtilAll; import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.remoting.RPCHook; import org.apache.rocketmq.remoting.RPCHook;
import org.springframework.util.StringUtils;
/** /**
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a> * @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
@ -94,7 +94,7 @@ public final class RocketMQUtils {
private static final String SQL = "sql:"; private static final String SQL = "sql:";
public static MessageSelector getMessageSelector(String expression) { public static MessageSelector getMessageSelector(String expression) {
if (StringUtils.hasText(expression) && expression.startsWith(SQL)) { if (StringUtils.isNotBlank(expression) && expression.startsWith(SQL)) {
return MessageSelector.bySql(expression.replaceFirst(SQL, "")); return MessageSelector.bySql(expression.replaceFirst(SQL, ""));
} }
return MessageSelector.byTag(expression); return MessageSelector.byTag(expression);

Loading…
Cancel
Save