Avoid Synthetic ctors
Private inner classes with a private ctor (real or implied) cause the compiler to generate synthetic package-visibility ctors, with a synthetic class parameter if needed. Also a few more lambdas. Avoid empty CTORs to avoid Sonar complaints.
This commit is contained in:
committed by
Artem Bilan
parent
75a4a8dd7d
commit
87e2fd4041
@@ -180,7 +180,7 @@ public final class BindingBuilder {
|
||||
|
||||
protected final String exchange;
|
||||
|
||||
private AbstractRoutingKeyConfigurer(DestinationConfigurer destination, String exchange) {
|
||||
AbstractRoutingKeyConfigurer(DestinationConfigurer destination, String exchange) {
|
||||
this.destination = destination;
|
||||
this.exchange = exchange;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class GZipPostProcessor extends AbstractDeflaterPostProcessor {
|
||||
|
||||
private static final class SettableLevelGZIPOutputStream extends GZIPOutputStream {
|
||||
|
||||
private SettableLevelGZIPOutputStream(OutputStream out, int level) throws IOException {
|
||||
SettableLevelGZIPOutputStream(OutputStream out, int level) throws IOException {
|
||||
super(out);
|
||||
this.def.setLevel(level);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ZipPostProcessor extends AbstractDeflaterPostProcessor {
|
||||
|
||||
private static final class SettableLevelZipOutputStream extends ZipOutputStream {
|
||||
|
||||
private SettableLevelZipOutputStream(OutputStream zipped, int level) {
|
||||
SettableLevelZipOutputStream(OutputStream zipped, int level) {
|
||||
super(zipped);
|
||||
this.setLevel(level);
|
||||
}
|
||||
|
||||
@@ -85,15 +85,22 @@ public class MarshallingMessageConverterTests {
|
||||
|
||||
private static class TestMarshaller implements Marshaller, Unmarshaller {
|
||||
|
||||
TestMarshaller() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Object graph, Result result) throws IOException, XmlMappingException {
|
||||
String response = ((String) graph).toUpperCase();
|
||||
((StreamResult) result).getOutputStream().write(response.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object unmarshal(Source source) throws IOException, XmlMappingException {
|
||||
byte[] buffer = new byte["UNMARSHAL TEST".length()];
|
||||
((StreamSource) source).getInputStream().read(buffer);
|
||||
|
||||
@@ -114,6 +114,10 @@ public class RabbitListenerTestHarness extends RabbitListenerAnnotationBeanPostP
|
||||
|
||||
private final BlockingQueue<InvocationData> invocationData = new LinkedBlockingQueue<InvocationData>();
|
||||
|
||||
CaptureAdvice() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
Object result = null;
|
||||
|
||||
@@ -44,6 +44,10 @@ public class AnswerTests {
|
||||
|
||||
private static class Foo {
|
||||
|
||||
Foo() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String foo(String foo) {
|
||||
return foo.toUpperCase();
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ public class AsyncRabbitTemplate implements AsyncAmqpTemplate, ChannelAwareMessa
|
||||
|
||||
private volatile RabbitConverterFuture<C> future;
|
||||
|
||||
private CorrelationMessagePostProcessor(MessagePostProcessor userPostProcessor,
|
||||
CorrelationMessagePostProcessor(MessagePostProcessor userPostProcessor,
|
||||
CorrelationData correlationData) {
|
||||
this.userPostProcessor = userPostProcessor;
|
||||
this.correlationData = correlationData;
|
||||
|
||||
@@ -726,6 +726,10 @@ public class RabbitListenerAnnotationBeanPostProcessor
|
||||
|
||||
private MessageHandlerMethodFactory messageHandlerMethodFactory;
|
||||
|
||||
RabbitHandlerMethodFactoryAdapter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory rabbitHandlerMethodFactory1) {
|
||||
this.messageHandlerMethodFactory = rabbitHandlerMethodFactory1;
|
||||
}
|
||||
|
||||
@@ -200,9 +200,6 @@ public abstract class RetryInterceptorBuilder<T extends MethodInterceptor> {
|
||||
public abstract T build();
|
||||
|
||||
|
||||
private RetryInterceptorBuilder() {
|
||||
}
|
||||
|
||||
public static final class StatefulRetryInterceptorBuilder extends RetryInterceptorBuilder<StatefulRetryOperationsInterceptor> {
|
||||
|
||||
private final StatefulRetryOperationsInterceptorFactoryBean factoryBean =
|
||||
@@ -212,6 +209,10 @@ public abstract class RetryInterceptorBuilder<T extends MethodInterceptor> {
|
||||
|
||||
private NewMessageIdentifier newMessageIdentifier;
|
||||
|
||||
StatefulRetryInterceptorBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stateful retry requires messages to be identifiable. Default is to use the message id header; use a custom
|
||||
* implementation if the message id is not present or not reliable.
|
||||
@@ -283,26 +284,25 @@ public abstract class RetryInterceptorBuilder<T extends MethodInterceptor> {
|
||||
return this.factoryBean.getObject();
|
||||
}
|
||||
|
||||
private StatefulRetryInterceptorBuilder() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static final class StatelessRetryInterceptorBuilder extends RetryInterceptorBuilder<RetryOperationsInterceptor> {
|
||||
public static final class StatelessRetryInterceptorBuilder
|
||||
extends RetryInterceptorBuilder<RetryOperationsInterceptor> {
|
||||
|
||||
private final StatelessRetryOperationsInterceptorFactoryBean factoryBean =
|
||||
new StatelessRetryOperationsInterceptorFactoryBean();
|
||||
|
||||
StatelessRetryInterceptorBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RetryOperationsInterceptor build() {
|
||||
this.applyCommonSettings(this.factoryBean);
|
||||
return this.factoryBean.getObject();
|
||||
}
|
||||
|
||||
private StatelessRetryInterceptorBuilder() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,9 +25,6 @@ import org.springframework.amqp.rabbit.retry.MessageKeyGenerator;
|
||||
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
|
||||
import org.springframework.amqp.rabbit.retry.NewMessageIdentifier;
|
||||
import org.springframework.retry.RetryOperations;
|
||||
import org.springframework.retry.interceptor.MethodArgumentsKeyGenerator;
|
||||
import org.springframework.retry.interceptor.MethodInvocationRecoverer;
|
||||
import org.springframework.retry.interceptor.NewMethodArgumentsIdentifier;
|
||||
import org.springframework.retry.interceptor.StatefulRetryOperationsInterceptor;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
|
||||
@@ -65,6 +62,7 @@ public class StatefulRetryOperationsInterceptorFactoryBean extends AbstractRetry
|
||||
this.newMessageIdentifier = newMessageIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatefulRetryOperationsInterceptor getObject() {
|
||||
|
||||
StatefulRetryOperationsInterceptor retryInterceptor = new StatefulRetryOperationsInterceptor();
|
||||
@@ -74,48 +72,42 @@ public class StatefulRetryOperationsInterceptorFactoryBean extends AbstractRetry
|
||||
}
|
||||
retryInterceptor.setRetryOperations(retryTemplate);
|
||||
|
||||
retryInterceptor.setNewItemIdentifier(new NewMethodArgumentsIdentifier() {
|
||||
public boolean isNew(Object[] args) {
|
||||
Message message = (Message) args[1];
|
||||
if (StatefulRetryOperationsInterceptorFactoryBean.this.newMessageIdentifier == null) {
|
||||
return !message.getMessageProperties().isRedelivered();
|
||||
}
|
||||
else {
|
||||
return StatefulRetryOperationsInterceptorFactoryBean.this.newMessageIdentifier.isNew(message);
|
||||
}
|
||||
retryInterceptor.setNewItemIdentifier(args -> {
|
||||
Message message = (Message) args[1];
|
||||
if (StatefulRetryOperationsInterceptorFactoryBean.this.newMessageIdentifier == null) {
|
||||
return !message.getMessageProperties().isRedelivered();
|
||||
}
|
||||
else {
|
||||
return StatefulRetryOperationsInterceptorFactoryBean.this.newMessageIdentifier.isNew(message);
|
||||
}
|
||||
});
|
||||
|
||||
final MessageRecoverer messageRecoverer = getMessageRecoverer();
|
||||
retryInterceptor.setRecoverer(new MethodInvocationRecoverer<Void>() {
|
||||
public Void recover(Object[] args, Throwable cause) {
|
||||
Message message = (Message) args[1];
|
||||
if (messageRecoverer == null) {
|
||||
logger.warn("Message dropped on recovery: " + message, cause);
|
||||
}
|
||||
else {
|
||||
messageRecoverer.recover(message, cause);
|
||||
}
|
||||
// This is actually a normal outcome. It means the recovery was successful, but we don't want to consume
|
||||
// any more messages until the acks and commits are sent for this (problematic) message...
|
||||
throw new ImmediateAcknowledgeAmqpException("Recovered message forces ack (if ack mode requires it): "
|
||||
+ message, cause);
|
||||
retryInterceptor.setRecoverer((args, cause) -> {
|
||||
Message message = (Message) args[1];
|
||||
if (messageRecoverer == null) {
|
||||
logger.warn("Message dropped on recovery: " + message, cause);
|
||||
}
|
||||
else {
|
||||
messageRecoverer.recover(message, cause);
|
||||
}
|
||||
// This is actually a normal outcome. It means the recovery was successful, but we don't want to consume
|
||||
// any more messages until the acks and commits are sent for this (problematic) message...
|
||||
throw new ImmediateAcknowledgeAmqpException("Recovered message forces ack (if ack mode requires it): "
|
||||
+ message, cause);
|
||||
});
|
||||
|
||||
retryInterceptor.setKeyGenerator(new MethodArgumentsKeyGenerator() {
|
||||
public Object getKey(Object[] args) {
|
||||
Message message = (Message) args[1];
|
||||
if (StatefulRetryOperationsInterceptorFactoryBean.this.messageKeyGenerator == null) {
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
if (messageId == null && message.getMessageProperties().isRedelivered()) {
|
||||
message.getMessageProperties().setFinalRetryForMessageWithNoId(true);
|
||||
}
|
||||
return messageId;
|
||||
}
|
||||
else {
|
||||
return StatefulRetryOperationsInterceptorFactoryBean.this.messageKeyGenerator.getKey(message);
|
||||
retryInterceptor.setKeyGenerator(args -> {
|
||||
Message message = (Message) args[1];
|
||||
if (StatefulRetryOperationsInterceptorFactoryBean.this.messageKeyGenerator == null) {
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
if (messageId == null && message.getMessageProperties().isRedelivered()) {
|
||||
message.getMessageProperties().setFinalRetryForMessageWithNoId(true);
|
||||
}
|
||||
return messageId;
|
||||
}
|
||||
else {
|
||||
return StatefulRetryOperationsInterceptorFactoryBean.this.messageKeyGenerator.getKey(message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -123,6 +115,7 @@ public class StatefulRetryOperationsInterceptorFactoryBean extends AbstractRetry
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return StatefulRetryOperationsInterceptor.class;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
|
||||
import org.springframework.retry.RetryOperations;
|
||||
import org.springframework.retry.interceptor.MethodInvocationRecoverer;
|
||||
import org.springframework.retry.interceptor.RetryOperationsInterceptor;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
|
||||
@@ -46,6 +45,7 @@ public class StatelessRetryOperationsInterceptorFactoryBean extends AbstractRetr
|
||||
|
||||
private static Log logger = LogFactory.getLog(StatelessRetryOperationsInterceptorFactoryBean.class);
|
||||
|
||||
@Override
|
||||
public RetryOperationsInterceptor getObject() {
|
||||
|
||||
RetryOperationsInterceptor retryInterceptor = new RetryOperationsInterceptor();
|
||||
@@ -56,23 +56,22 @@ public class StatelessRetryOperationsInterceptorFactoryBean extends AbstractRetr
|
||||
retryInterceptor.setRetryOperations(retryTemplate);
|
||||
|
||||
final MessageRecoverer messageRecoverer = getMessageRecoverer();
|
||||
retryInterceptor.setRecoverer(new MethodInvocationRecoverer<Void>() {
|
||||
public Void recover(Object[] args, Throwable cause) {
|
||||
Message message = (Message) args[1];
|
||||
if (messageRecoverer == null) {
|
||||
logger.warn("Message dropped on recovery: " + message, cause);
|
||||
}
|
||||
else {
|
||||
messageRecoverer.recover(message, cause);
|
||||
}
|
||||
return null;
|
||||
retryInterceptor.setRecoverer((args, cause) -> {
|
||||
Message message = (Message) args[1];
|
||||
if (messageRecoverer == null) {
|
||||
logger.warn("Message dropped on recovery: " + message, cause);
|
||||
}
|
||||
else {
|
||||
messageRecoverer.recover(message, cause);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
return retryInterceptor;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return RetryOperationsInterceptor.class;
|
||||
}
|
||||
|
||||
@@ -847,7 +847,7 @@ public class CachingConnectionFactory extends AbstractConnectionFactory
|
||||
|
||||
private final boolean transactional;
|
||||
|
||||
private CachedChannelInvocationHandler(ChannelCachingConnectionProxy connection,
|
||||
CachedChannelInvocationHandler(ChannelCachingConnectionProxy connection,
|
||||
Channel target,
|
||||
LinkedList<ChannelProxy> channelList,
|
||||
boolean transactional) {
|
||||
@@ -1022,34 +1022,29 @@ public class CachingConnectionFactory extends AbstractConnectionFactory
|
||||
? getExecutorService()
|
||||
: CachingConnectionFactory.this.deferredCloseExecutor);
|
||||
final Channel channel = CachedChannelInvocationHandler.this.target;
|
||||
executorService.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (CachingConnectionFactory.this.publisherConfirms) {
|
||||
channel.waitForConfirmsOrDie(5000);
|
||||
}
|
||||
else {
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
if (CachingConnectionFactory.this.publisherConfirms) {
|
||||
channel.waitForConfirmsOrDie(5000);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
catch (Exception e) { }
|
||||
finally {
|
||||
try {
|
||||
if (channel.isOpen()) {
|
||||
channel.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) { }
|
||||
catch (AlreadyClosedException e) { }
|
||||
catch (TimeoutException e) { }
|
||||
else {
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
catch (InterruptedException e1) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
catch (Exception e2) { }
|
||||
finally {
|
||||
try {
|
||||
if (channel.isOpen()) {
|
||||
channel.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e3) { }
|
||||
catch (AlreadyClosedException e4) { }
|
||||
catch (TimeoutException e5) { }
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -1074,7 +1069,7 @@ public class CachingConnectionFactory extends AbstractConnectionFactory
|
||||
|
||||
private final AtomicBoolean closeNotified = new AtomicBoolean(false);
|
||||
|
||||
private ChannelCachingConnectionProxy(Connection target) {
|
||||
ChannelCachingConnectionProxy(Connection target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@@ -1184,6 +1179,10 @@ public class CachingConnectionFactory extends AbstractConnectionFactory
|
||||
*/
|
||||
private static class DefaultChannelCloseLogger implements ConditionalExceptionLogger {
|
||||
|
||||
DefaultChannelCloseLogger() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Log logger, String message, Throwable t) {
|
||||
if (t instanceof ShutdownSignalException) {
|
||||
|
||||
@@ -248,7 +248,7 @@ public final class ConnectionFactoryUtils {
|
||||
|
||||
private final RabbitResourceHolder resourceHolder;
|
||||
|
||||
private RabbitResourceSynchronization(RabbitResourceHolder resourceHolder, Object resourceKey) {
|
||||
RabbitResourceSynchronization(RabbitResourceHolder resourceHolder, Object resourceKey) {
|
||||
super(resourceHolder, resourceKey);
|
||||
this.resourceHolder = resourceHolder;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public final class ConsumerChannelRegistry {
|
||||
|
||||
private final ConnectionFactory connectionFactory;
|
||||
|
||||
private ChannelHolder(Channel channel, ConnectionFactory connectionFactory) {
|
||||
ChannelHolder(Channel channel, ConnectionFactory connectionFactory) {
|
||||
this.channel = channel;
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
@@ -76,13 +76,7 @@ public class BatchingRabbitTemplate extends RabbitTemplate implements Lifecycle
|
||||
}
|
||||
Date next = this.batchingStrategy.nextRelease();
|
||||
if (next != null) {
|
||||
this.scheduledTask = this.scheduler.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
releaseBatches();
|
||||
}
|
||||
}, next);
|
||||
this.scheduledTask = this.scheduler.schedule((Runnable) () -> releaseBatches(), next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1539,6 +1539,10 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor
|
||||
*/
|
||||
private static class DefaultExclusiveConsumerLogger implements ConditionalExceptionLogger {
|
||||
|
||||
DefaultExclusiveConsumerLogger() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Log logger, String message, Throwable t) {
|
||||
if (t instanceof ShutdownSignalException) {
|
||||
|
||||
@@ -715,7 +715,7 @@ public class BlockingQueueConsumer {
|
||||
|
||||
private final class InternalConsumer extends DefaultConsumer {
|
||||
|
||||
private InternalConsumer(Channel channel) {
|
||||
InternalConsumer(Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ public class BlockingQueueConsumer {
|
||||
@SuppressWarnings("serial")
|
||||
private static final class DeclarationException extends AmqpException {
|
||||
|
||||
private DeclarationException() {
|
||||
DeclarationException() {
|
||||
super("Failed to declare queue(s):");
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +200,8 @@ public class RabbitListenerEndpointRegistrar implements BeanFactoryAware, Initia
|
||||
|
||||
private final RabbitListenerContainerFactory<?> containerFactory;
|
||||
|
||||
private AmqpListenerEndpointDescriptor(RabbitListenerEndpoint endpoint, RabbitListenerContainerFactory<?> containerFactory) {
|
||||
AmqpListenerEndpointDescriptor(RabbitListenerEndpoint endpoint,
|
||||
RabbitListenerContainerFactory<?> containerFactory) {
|
||||
this.endpoint = endpoint;
|
||||
this.containerFactory = containerFactory;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ public class RabbitListenerEndpointRegistry implements DisposableBean, SmartLife
|
||||
|
||||
private final Runnable finishCallback;
|
||||
|
||||
private AggregatingCallback(int count, Runnable finishCallback) {
|
||||
AggregatingCallback(int count, Runnable finishCallback) {
|
||||
this.count = new AtomicInteger(count);
|
||||
this.finishCallback = finishCallback;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,6 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -721,22 +719,19 @@ public class SimpleMessageListenerContainer extends AbstractMessageListenerConta
|
||||
if (getTransactionManager() != null) {
|
||||
try {
|
||||
return new TransactionTemplate(getTransactionManager(), getTransactionAttribute())
|
||||
.execute(new TransactionCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInTransaction(TransactionStatus status) {
|
||||
ConnectionFactoryUtils.bindResourceToTransaction(
|
||||
new RabbitResourceHolder(consumer.getChannel(), false),
|
||||
getConnectionFactory(), true);
|
||||
try {
|
||||
return doReceiveAndExecute(consumer);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) { //NOSONAR
|
||||
// ok to catch Throwable here because we re-throw it below
|
||||
throw new WrappedTransactionException(e);
|
||||
}
|
||||
.execute(status -> {
|
||||
ConnectionFactoryUtils.bindResourceToTransaction(
|
||||
new RabbitResourceHolder(consumer.getChannel(), false),
|
||||
getConnectionFactory(), true);
|
||||
try {
|
||||
return doReceiveAndExecute(consumer);
|
||||
}
|
||||
catch (RuntimeException e1) {
|
||||
throw e1;
|
||||
}
|
||||
catch (Throwable e2) { //NOSONAR
|
||||
// ok to catch Throwable here because we re-throw it below
|
||||
throw new WrappedTransactionException(e2);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -827,7 +822,7 @@ public class SimpleMessageListenerContainer extends AbstractMessageListenerConta
|
||||
|
||||
private volatile FatalListenerStartupException startupException;
|
||||
|
||||
private AsyncMessageProcessingConsumer(BlockingQueueConsumer consumer) {
|
||||
AsyncMessageProcessingConsumer(BlockingQueueConsumer consumer) {
|
||||
this.consumer = consumer;
|
||||
this.start = new CountDownLatch(1);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageLis
|
||||
|
||||
private final Type inferredArgumentType;
|
||||
|
||||
private MessagingMessageConverterAdapter(Object bean, Method method) {
|
||||
MessagingMessageConverterAdapter(Object bean, Method method) {
|
||||
this.bean = bean;
|
||||
this.method = method;
|
||||
this.inferredArgumentType = determineInferredType();
|
||||
|
||||
@@ -112,12 +112,14 @@ public class RabbitTransactionManager extends AbstractPlatformTransactionManager
|
||||
/**
|
||||
* Make sure the ConnectionFactory has been set.
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (getConnectionFactory() == null) {
|
||||
throw new IllegalArgumentException("Property 'connectionFactory' is required");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResourceFactory() {
|
||||
return getConnectionFactory();
|
||||
}
|
||||
@@ -215,6 +217,10 @@ public class RabbitTransactionManager extends AbstractPlatformTransactionManager
|
||||
|
||||
private RabbitResourceHolder resourceHolder;
|
||||
|
||||
RabbitTransactionObject() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setResourceHolder(RabbitResourceHolder resourceHolder) {
|
||||
this.resourceHolder = resourceHolder;
|
||||
}
|
||||
@@ -223,10 +229,12 @@ public class RabbitTransactionManager extends AbstractPlatformTransactionManager
|
||||
return this.resourceHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRollbackOnly() {
|
||||
return this.resourceHolder.isRollbackOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@@ -131,6 +131,10 @@ public class RabbitListenerContainerFactoryIntegrationTests {
|
||||
|
||||
private static class UpperCaseMessageConverter implements MessageConverter {
|
||||
|
||||
UpperCaseMessageConverter() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toMessage(Object object, MessageProperties messageProperties) throws MessageConversionException {
|
||||
return new Message(object.toString().toUpperCase().getBytes(), new MessageProperties());
|
||||
|
||||
@@ -247,14 +247,9 @@ public class RetryInterceptorBuilderSupportTests {
|
||||
}
|
||||
|
||||
private Foo createDelegate(MethodInterceptor interceptor, final AtomicInteger count) {
|
||||
Foo delegate = new Foo() {
|
||||
|
||||
@Override
|
||||
public void onMessage(String s, Message message) {
|
||||
count.incrementAndGet();
|
||||
throw new RuntimeException("foo", new RuntimeException("bar"));
|
||||
}
|
||||
|
||||
Foo delegate = (s, message) -> {
|
||||
count.incrementAndGet();
|
||||
throw new RuntimeException("foo", new RuntimeException("bar"));
|
||||
};
|
||||
ProxyFactory factory = new ProxyFactory();
|
||||
factory.addAdvisor(new DefaultPointcutAdvisor(Pointcut.TRUE, interceptor));
|
||||
|
||||
@@ -362,21 +362,13 @@ public class CachingConnectionFactoryTests extends AbstractConnectionFactoryTest
|
||||
ccf.setChannelCheckoutTimeout(10);
|
||||
ccf.setCacheMode(mode);
|
||||
|
||||
ccf.addConnectionListener(new ConnectionListener() { // simulate admin
|
||||
|
||||
@Override
|
||||
public void onCreate(Connection connection) {
|
||||
try {
|
||||
connection.createChannel(false).close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
ccf.addConnectionListener(connection -> {
|
||||
try {
|
||||
// simulate admin
|
||||
connection.createChannel(false).close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(Connection connection) {
|
||||
// empty
|
||||
catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -131,6 +131,10 @@ public class RabbitTemplatePerformanceIntegrationTests {
|
||||
@SuppressWarnings("serial")
|
||||
private class TestTransactionManager extends AbstractPlatformTransactionManager {
|
||||
|
||||
TestTransactionManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ import org.springframework.amqp.support.ConsumerTagStrategy;
|
||||
import org.springframework.amqp.support.converter.MessageConversionException;
|
||||
import org.springframework.amqp.utils.test.TestUtils;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -262,24 +261,15 @@ public class DirectMessageListenerContainerTests {
|
||||
final CountDownLatch latch1 = new CountDownLatch(2);
|
||||
final AtomicReference<ApplicationEvent> failEvent = new AtomicReference<>();
|
||||
final CountDownLatch latch2 = new CountDownLatch(2);
|
||||
container.setApplicationEventPublisher(new ApplicationEventPublisher() {
|
||||
|
||||
@Override
|
||||
public void publishEvent(Object event) {
|
||||
container.setApplicationEventPublisher(event -> {
|
||||
if (event instanceof ListenerContainerIdleEvent) {
|
||||
times.add(System.currentTimeMillis());
|
||||
latch1.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishEvent(ApplicationEvent event) {
|
||||
if (event instanceof ListenerContainerIdleEvent) {
|
||||
times.add(System.currentTimeMillis());
|
||||
latch1.countDown();
|
||||
}
|
||||
else {
|
||||
failEvent.set(event);
|
||||
latch2.countDown();
|
||||
}
|
||||
else {
|
||||
failEvent.set((ApplicationEvent) event);
|
||||
latch2.countDown();
|
||||
}
|
||||
|
||||
});
|
||||
container.setMessageListener(m -> { });
|
||||
container.setIdleEventInterval(50L);
|
||||
|
||||
@@ -175,6 +175,10 @@ public class MessageListenerRecoveryRepeatIntegrationTests {
|
||||
|
||||
private CountDownLatch latch;
|
||||
|
||||
CloseConnectionListener() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setLatch(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
failed.set(false);
|
||||
|
||||
@@ -580,11 +580,19 @@ public class SimpleMessageListenerContainerIntegration2Tests {
|
||||
@SuppressWarnings("serial")
|
||||
private static final class Foo implements Serializable {
|
||||
|
||||
Foo() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static final class Bar implements Serializable {
|
||||
|
||||
Bar() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -409,6 +409,10 @@ public class SimpleMessageListenerContainerIntegrationTests {
|
||||
@SuppressWarnings("serial")
|
||||
private class TestTransactionManager extends AbstractPlatformTransactionManager {
|
||||
|
||||
TestTransactionManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
|
||||
}
|
||||
|
||||
@@ -112,6 +112,10 @@ public final class SimpleMessageListenerWithRabbitMQ {
|
||||
|
||||
private static class SimpleAdapter {
|
||||
|
||||
SimpleAdapter() {
|
||||
super();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void handleMessage(String input) {
|
||||
logger.debug("Got it: " + input);
|
||||
|
||||
@@ -175,6 +175,10 @@ public class MessagingMessageListenerAdapterTests {
|
||||
|
||||
private Object payload;
|
||||
|
||||
SampleBean() {
|
||||
super();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Message<String> echo(Message<String> input) {
|
||||
return MessageBuilder.withPayload(input.getPayload())
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class RabbitMatchers {
|
||||
|
||||
private final String pattern;
|
||||
|
||||
private RegexMatcher(String pattern) {
|
||||
RegexMatcher(String pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user