diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java index 660a666ae7..a4cd5acc8d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. You may obtain a copy of the License at @@ -16,6 +16,7 @@ package org.springframework.integration.aggregator; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.apache.commons.logging.Log; @@ -41,6 +42,7 @@ import org.springframework.util.Assert; * @author Alexander Peters * @author Mark Fisher * @author Dave Syer + * @author Gary Russell * @since 2.0 */ public abstract class AbstractAggregatingMessageGroupProcessor implements MessageGroupProcessor, @@ -84,13 +86,13 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag Map aggregatedHeaders = new HashMap(); Set conflictKeys = new HashSet(); for (Message message : group.getMessages()) { - MessageHeaders currentHeaders = message.getHeaders(); - for (String key : currentHeaders.keySet()) { + for (Entry entry : message.getHeaders().entrySet()) { + String key = entry.getKey(); if (MessageHeaders.ID.equals(key) || MessageHeaders.TIMESTAMP.equals(key) || IntegrationMessageHeaderAccessor.SEQUENCE_SIZE.equals(key) || IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER.equals(key)) { continue; } - Object value = currentHeaders.get(key); + Object value = entry.getValue(); if (!aggregatedHeaders.containsKey(key)) { aggregatedHeaders.put(key, value); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MethodInvokingCorrelationStrategy.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MethodInvokingCorrelationStrategy.java index b5f4c1ef72..5372a1e0aa 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MethodInvokingCorrelationStrategy.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MethodInvokingCorrelationStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -21,7 +21,6 @@ import java.lang.reflect.Method; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.handler.MessageProcessor; import org.springframework.integration.handler.MethodInvokingMessageProcessor; import org.springframework.messaging.Message; import org.springframework.util.Assert; @@ -32,10 +31,11 @@ import org.springframework.util.Assert; * @author Marius Bogoevici * @author Dave Syer * @author Artem Bilan + * @author Gary Russell */ public class MethodInvokingCorrelationStrategy implements CorrelationStrategy, BeanFactoryAware { - private final MessageProcessor processor; + private final MethodInvokingMessageProcessor processor; public MethodInvokingCorrelationStrategy(Object object, String methodName) { this.processor = new MethodInvokingMessageProcessor(object, methodName, true); @@ -50,8 +50,8 @@ public class MethodInvokingCorrelationStrategy implements CorrelationStrategy, B @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - if (beanFactory != null && this.processor instanceof BeanFactoryAware) { - ((BeanFactoryAware) this.processor).setBeanFactory(beanFactory); + if (beanFactory != null) { + this.processor.setBeanFactory(beanFactory); } } @@ -59,4 +59,5 @@ public class MethodInvokingCorrelationStrategy implements CorrelationStrategy, B public Object getCorrelationKey(Message message) { return processor.processMessage(message); } + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/FixedSubscriberChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/FixedSubscriberChannel.java index 70faa93fe9..a1c7e4f3b2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/FixedSubscriberChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/FixedSubscriberChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 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. @@ -21,7 +21,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.BeanNameAware; import org.springframework.integration.support.context.NamedComponent; import org.springframework.messaging.Message; -import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessagingException; import org.springframework.messaging.SubscribableChannel; @@ -70,16 +69,14 @@ public final class FixedSubscriberChannel implements SubscribableChannel, BeanNa this.handler.handleMessage(message); return true; } - catch (Exception e) { - RuntimeException runtimeException = (e instanceof RuntimeException) - ? (RuntimeException) e - : new MessageDeliveryException(message, - this.getComponentName() + " failed to deliver Message.", e); + catch (RuntimeException e) { if (e instanceof MessagingException && ((MessagingException) e).getFailedMessage() == null) { - runtimeException = new MessagingException(message, e); + throw new MessagingException(message, e); + } + else { + throw e; } - throw runtimeException; } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java index b413144152..e39ed896be 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -70,7 +70,7 @@ final class GlobalChannelInterceptorProcessor implements BeanFactoryAware, Smart @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { Assert.isInstanceOf(ListableBeanFactory.class, beanFactory); - this.beanFactory = (ListableBeanFactory) beanFactory; + this.beanFactory = (ListableBeanFactory) beanFactory;//NOSONAR (inconsistent sync) } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java index 94cbd6d6d1..2443f491ac 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 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. @@ -37,18 +37,19 @@ import org.springframework.util.PatternMatchUtils; * to {@link MessageHandler}s mapped by their {@code endpoint beanName}. * * @author Artem Bilan + * @author Gary Russell * @since 4.1 */ @SuppressWarnings("serial") class IdempotentReceiverAutoProxyCreator extends AbstractAutoProxyCreator { - private List> idempotentEndpointsMapping; + private volatile List> idempotentEndpointsMapping; - private Map> idempotentEndpoints; + private volatile Map> idempotentEndpoints; // double check locking requires volatile public void setIdempotentEndpointsMapping(List> idempotentEndpointsMapping) { Assert.notEmpty(idempotentEndpointsMapping); - this.idempotentEndpointsMapping = idempotentEndpointsMapping; + this.idempotentEndpointsMapping = idempotentEndpointsMapping;//NOSONAR (inconsistent sync) } @Override @@ -82,7 +83,7 @@ class IdempotentReceiverAutoProxyCreator extends AbstractAutoProxyCreator { } private void initIdempotentEndpointsIfNecessary() { - if (this.idempotentEndpoints == null) { + if (this.idempotentEndpoints == null) {//NOSONAR (inconsistent sync) synchronized (this) { if (this.idempotentEndpoints == null) { this.idempotentEndpoints = new LinkedHashMap>(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceUtils.java index 2e0ef14bb5..5b6c13cd85 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. You may obtain a copy of the License at @@ -300,8 +300,7 @@ public abstract class IntegrationNamespaceUtils { String ref = element.getAttribute(REF_ATTRIBUTE); if (StringUtils.hasText(ref) && innerComponentDefinition != null) { parserContext.getReaderContext().error( - "Ambiguous definition. Inner bean " + (innerComponentDefinition == null ? innerComponentDefinition - : innerComponentDefinition.getBeanDefinition().getBeanClassName()) + "Ambiguous definition. Inner bean " + (innerComponentDefinition.getBeanDefinition().getBeanClassName()) + " declaration and \"ref\" " + ref + " are not allowed together on element " + IntegrationNamespaceUtils.createElementDescription(element) + ".", parserContext.extractSource(element)); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java b/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java index ad7819d95a..a2ac2cba2d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/UnicastingDispatcher.java @@ -147,7 +147,7 @@ public class UnicastingDispatcher extends AbstractDispatcher { if (allExceptions != null && allExceptions.size() == 1) { throw allExceptions.get(0); } - throw new AggregateMessageDeliveryException(message, + throw new AggregateMessageDeliveryException(message,//NOSONAR - false positive "All attempts to deliver Message to MessageHandlers failed.", allExceptions); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java index c5b8edd7f5..62e4f69415 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -116,10 +116,6 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement return; } Assert.notNull(this.trigger, "Trigger is required"); - Executor providedExecutor = this.taskExecutor; - if (providedExecutor != null) { - this.taskExecutor = providedExecutor; - } if (this.taskExecutor != null) { if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) { if (this.errorHandler == null) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java index 6f27b82095..39bfb8329c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -22,7 +22,6 @@ import org.springframework.integration.history.MessageHistory; import org.springframework.integration.history.TrackableComponent; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.ErrorMessage; import org.springframework.util.Assert; @@ -33,6 +32,7 @@ import org.springframework.util.Assert; * * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell */ public abstract class MessageProducerSupport extends AbstractEndpoint implements MessageProducer, TrackableComponent { @@ -100,15 +100,12 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements try { this.messagingTemplate.send(this.outputChannel, message); } - catch (Exception e) { + catch (RuntimeException e) { if (this.errorChannel != null) { this.messagingTemplate.send(this.errorChannel, new ErrorMessage(e)); } - else if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } - else { - throw new MessageDeliveryException(message, "failed to send message", e); + else { + throw e; } } } 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 9634ebc9eb..e686fc6d40 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 @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -203,7 +204,8 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper argumentValue, Map headers) { - for (Object key : argumentValue.keySet()) { + for (Entry entry : argumentValue.entrySet()) { + Object key = entry.getKey(); if (!(key instanceof String)) { if (this.logger.isWarnEnabled()){ this.logger.warn("Invalid header name [" + key + @@ -211,8 +213,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper message) { - try { - return this.processor.processMessage(message); - } - catch (Exception e) { - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } - throw new MessageHandlingException(message, "failure occurred in '" + this + "'", e); - } + return this.processor.processMessage(message); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/mapping/AbstractHeaderMapper.java b/spring-integration-core/src/main/java/org/springframework/integration/mapping/AbstractHeaderMapper.java index edf4986319..515d417dd9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/mapping/AbstractHeaderMapper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/mapping/AbstractHeaderMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,6 +41,7 @@ import org.springframework.util.StringUtils; * @author Mark Fisher * @author Oleg Zhurakousky * @author Stephane Nicoll + * @author Gary Russell * @since 2.1 */ public abstract class AbstractHeaderMapper implements RequestReplyHeaderMapper { @@ -195,8 +197,9 @@ public abstract class AbstractHeaderMapper implements RequestReplyHeaderMappe } private void populateUserDefinedHeaders(Map headers, T target) { - for (String headerName : headers.keySet()) { - Object value = headers.get(headerName); + for (Entry entry : headers.entrySet()) { + String headerName = entry.getKey(); + Object value = entry.getValue(); if (value != null && !isMessageChannel(headerName, value)) { try { if (!headerName.startsWith(this.standardHeaderPrefix)) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/PayloadTypeRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/PayloadTypeRouter.java index 1cd35d1aea..d0b414d265 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/PayloadTypeRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/PayloadTypeRouter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2015 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. @@ -27,9 +27,10 @@ import org.springframework.util.CollectionUtils; /** * A Message Router that resolves the {@link MessageChannel} based on the * {@link Message Message's} payload type. - * + * * @author Mark Fisher * @author Oleg Zhurakousky + * @author Gary Russell */ public class PayloadTypeRouter extends AbstractMappingMessageRouter { @@ -102,7 +103,7 @@ public class PayloadTypeRouter extends AbstractMappingMessageRouter { } for (Class iface : type.getInterfaces()) { if (iface.getName().equals(candidate)) { - return (level % 2 == 1) ? level + 2 : level + 1; + return (level % 2 != 0) ? level + 2 : level + 1; } // no match at this level, continue up the hierarchy for (Class superInterface : iface.getInterfaces()) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java index 92bdf07de7..2b606490df 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -18,6 +18,7 @@ package org.springframework.integration.transformer; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,6 +41,7 @@ import org.springframework.messaging.MessagingException; * @author Mark Fisher * @author David Turanski * @author Artem Bilan + * @author Gary Russell */ public class HeaderEnricher extends IntegrationObjectSupport implements Transformer, BeanNameAware, InitializingBean { @@ -127,16 +129,16 @@ public class HeaderEnricher extends IntegrationObjectSupport implements Transfor } } - @SuppressWarnings("rawtypes") private void addHeadersFromMessageProcessor(Message message, Map headerMap) { if (this.messageProcessor != null) { Object result = this.messageProcessor.processMessage(message); if (result instanceof Map) { - Map resultMap = (Map) result; - for (Object key : resultMap.keySet()) { + Map resultMap = (Map) result; + for (Entry entry : resultMap.entrySet()) { + Object key = entry.getKey(); if (key instanceof String) { if (this.defaultOverwrite || headerMap.get(key) == null) { - headerMap.put((String) key, resultMap.get(key)); + headerMap.put((String) key, entry.getValue()); } } else if (logger.isDebugEnabled()) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java index d5123fd68d..2d80e60a4a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -19,9 +19,10 @@ package org.springframework.integration.transformer; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; -import org.springframework.integration.support.json.JsonObjectMapperProvider; import org.springframework.integration.support.json.JsonObjectMapper; +import org.springframework.integration.support.json.JsonObjectMapperProvider; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -50,6 +51,7 @@ import org.springframework.util.StringUtils; * * @author Oleg Zhurakousky * @author Artem Bilan + * @author Gary Russell * @since 2.0 */ public class ObjectToMapTransformer extends AbstractPayloadTransformer> { @@ -104,9 +106,8 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer entry : inputMap.entrySet()) { + this.doProcessElement(propertyPrefix + entry.getKey(), entry.getValue(), resultMap); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java index dbf3a4f090..1069dbce34 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 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. @@ -42,6 +42,7 @@ import org.springframework.util.Assert; * with the {@code path} as {@code key} and {@code 0} as initial {@code routingSlipIndex}. * * @author Artem Bilan + * @author Gary Russell * @since 4.1 */ public class RoutingSlipHeaderValueMessageProcessor @@ -74,17 +75,21 @@ public class RoutingSlipHeaderValueMessageProcessor @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { Assert.notNull(beanFactory, "BeanFactory must not be null"); - this.beanFactory = beanFactory; - this.evaluationContext = IntegrationContextUtils.getEvaluationContext(beanFactory); + this.beanFactory = beanFactory;//NOSONAR (inconsistent sync) + this.evaluationContext = IntegrationContextUtils.getEvaluationContext(beanFactory);//NOSONAR (inconsistent sync) } @Override public Map, Integer> processMessage(Message message) { - if (this.routingSlip == null) { + // use a local variable to avoid the second access to volatile field on the happy path + Map, Integer> routingSlip = this.routingSlip; + if (routingSlip == null) { synchronized (this) { - if (this.routingSlip == null) { - List routingSlipValues = new ArrayList(this.routingSlipPath.size()); - for (Object path : this.routingSlipPath) { + routingSlip = this.routingSlip; + if (routingSlip == null) { + List routingSlipPath = this.routingSlipPath; + List routingSlipValues = new ArrayList(routingSlipPath.size()); + for (Object path : routingSlipPath) { if (path instanceof String) { String entry = (String) path; if (this.beanFactory.containsBean(entry)) { @@ -108,10 +113,11 @@ public class RoutingSlipHeaderValueMessageProcessor } } - this.routingSlip = Collections.singletonMap(Collections.unmodifiableList(routingSlipValues), 0); + routingSlip = Collections.singletonMap(Collections.unmodifiableList(routingSlipValues), 0); + this.routingSlip = routingSlip; } } } - return this.routingSlip; + return routingSlip; } } diff --git a/spring-integration-feed/src/main/java/org/springframework/integration/feed/inbound/FeedEntryMessageSource.java b/spring-integration-feed/src/main/java/org/springframework/integration/feed/inbound/FeedEntryMessageSource.java index 0cfcea1347..98ed1c531b 100644 --- a/spring-integration-feed/src/main/java/org/springframework/integration/feed/inbound/FeedEntryMessageSource.java +++ b/spring-integration-feed/src/main/java/org/springframework/integration/feed/inbound/FeedEntryMessageSource.java @@ -169,7 +169,7 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements this.lastTime = next.getPublishedDate().getTime(); } else { - this.lastTime += 1; + this.lastTime += 1;//NOSONAR - single poller thread } this.metadataStore.put(this.metadataKey, this.lastTime + ""); return next; diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java index dd482f137f..a2ee362ebf 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -528,7 +528,7 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply String path = this.doPut(this.getMessageBuilderFactory().withPayload(filteredFile) .copyHeaders(requestMessage.getHeaders()) .build(), subDirectory); - if (path == null) { + if (path == null) {//NOSONAR - false positive if (logger.isDebugEnabled()) { logger.debug("File " + filteredFile.getAbsolutePath() + " removed before transfer; ignoring"); } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java index 9785ab9dd9..0b98a341a3 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java @@ -16,7 +16,6 @@ package org.springframework.integration.file.remote.synchronizer; -import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -167,13 +166,11 @@ public abstract class AbstractInboundFileSynchronizingMessageSource @Override public void stop() { this.running = false; - if (this.synchronizer instanceof Closeable) { - try { - ((Closeable) this.synchronizer).close(); - } - catch (IOException e) { - logger.error("Error closing synchronizer", e); - } + try { + this.synchronizer.close(); + } + catch (IOException e) { + logger.error("Error closing synchronizer", e); } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/test/BigMGetTests.java b/spring-integration-file/src/main/java/org/springframework/integration/file/test/BigMGetTests.java index c3310def54..93092edf15 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/test/BigMGetTests.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/test/BigMGetTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -48,7 +48,7 @@ public abstract class BigMGetTests { for (int i = 0; i < FILES; i++) { File f = new File("/tmp/bigmget/file" + i); f.createNewFile(); - FileOutputStream fos = new FileOutputStream(f); + FileOutputStream fos = new FileOutputStream(f);//NOSONAR fos.write(buff); fos.close(); } diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/DefaultFtpsSessionFactory.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/DefaultFtpsSessionFactory.java index f33fa8e07a..bebbf0ad87 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/DefaultFtpsSessionFactory.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/DefaultFtpsSessionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2015 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. @@ -17,19 +17,22 @@ package org.springframework.integration.ftp.session; import java.io.IOException; +import java.util.Arrays; import javax.net.ssl.KeyManager; import javax.net.ssl.TrustManager; import org.apache.commons.net.ftp.FTPSClient; + import org.springframework.util.StringUtils; /** * SessionFactory for FTPS. - * + * * @author Josh Long * @author Iwein Fuld * @author Mark Fisher + * @author Gary Russell * @since 2.0 */ public class DefaultFtpsSessionFactory extends AbstractFtpSessionFactory { @@ -80,11 +83,11 @@ public class DefaultFtpsSessionFactory extends AbstractFtpSessionFactorymultipart/form-data content in an HTTP request. * * @author Mark Fisher + * @author Gary Russell * @since 2.0 */ public class MultipartAwareFormHttpMessageConverter implements HttpMessageConverter> { @@ -112,11 +114,10 @@ public class MultipartAwareFormHttpMessageConverter implements HttpMessageConver private MultiValueMap readMultipart(MultipartHttpInputMessage multipartRequest) throws IOException { MultiValueMap resultMap = new LinkedMultiValueMap(); Map parameterMap = multipartRequest.getParameterMap(); - for (Object key : parameterMap.keySet()) { - resultMap.add((String) key, parameterMap.get(key)); + for (Entry entry : parameterMap.entrySet()) { + resultMap.add((String) entry.getKey(), entry.getValue()); } - Map fileMap = multipartRequest.getFileMap(); - for (Map.Entry entry : fileMap.entrySet()) { + for (Map.Entry entry : multipartRequest.getFileMap().entrySet()) { MultipartFile multipartFile = entry.getValue(); if (multipartFile.isEmpty()) { continue; diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/converter/SerializingHttpMessageConverter.java b/spring-integration-http/src/main/java/org/springframework/integration/http/converter/SerializingHttpMessageConverter.java index f497cd9b84..4ecab84ae1 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/converter/SerializingHttpMessageConverter.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/converter/SerializingHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -61,7 +61,7 @@ public class SerializingHttpMessageConverter extends AbstractHttpMessageConverte @SuppressWarnings("rawtypes") public Serializable readInternal(Class clazz, HttpInputMessage inputMessage) throws IOException { try { - return (Serializable) new ObjectInputStream(inputMessage.getBody()).readObject(); + return (Serializable) new ObjectInputStream(inputMessage.getBody()).readObject();//NOSONAR } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java b/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java index 226be9969d..68377ae17a 100755 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import javax.xml.transform.Source; @@ -556,11 +557,11 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe private MultiValueMap convertToMultiValueMap(Map simpleMap) { LinkedMultiValueMap multipartValueMap = new LinkedMultiValueMap(); - for (Object key : simpleMap.keySet()) { - Object value = simpleMap.get(key); + for (Entry entry : simpleMap.entrySet()) { + Object key = entry.getKey(); + Object value = entry.getValue(); if (value instanceof Object[]) { - Object[] valueArray = (Object[]) value; - value = Arrays.asList(valueArray); + value = Arrays.asList((Object[]) value); } if (value instanceof Collection) { multipartValueMap.put(key, new ArrayList((Collection) value)); @@ -577,8 +578,7 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe * the Map to be multipart/form-data */ private boolean isMultipart(Map map) { - for (String key : map.keySet()) { - Object value = map.get(key); + for (Object value : map.values()) { if (value != null) { if (value.getClass().isArray()) { value = CollectionUtils.arrayToList(value); diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/support/DefaultHttpHeaderMapper.java b/spring-integration-http/src/main/java/org/springframework/integration/http/support/DefaultHttpHeaderMapper.java index c92d2ad9ac..ccef34032e 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/support/DefaultHttpHeaderMapper.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/support/DefaultHttpHeaderMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -33,6 +33,7 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.TimeZone; @@ -308,7 +309,7 @@ public class DefaultHttpHeaderMapper implements HeaderMapper, BeanF public void setOutboundHeaderNames(String[] outboundHeaderNames) { this.outboundHeaderNames = (outboundHeaderNames != null) ? outboundHeaderNames : new String[0]; this.outboundHeaderNamesLower = new String[this.outboundHeaderNames.length]; - for (int i = 0; i < outboundHeaderNames.length; i++) { + for (int i = 0; i < this.outboundHeaderNames.length; i++) { if (HTTP_REQUEST_HEADER_NAME_PATTERN.equals(this.outboundHeaderNames[i]) || HTTP_RESPONSE_HEADER_NAME_PATTERN.equals(this.outboundHeaderNames[i])) { this.outboundHeaderNamesLower[i] = this.outboundHeaderNames[i]; @@ -335,7 +336,7 @@ public class DefaultHttpHeaderMapper implements HeaderMapper, BeanF public void setInboundHeaderNames(String[] inboundHeaderNames) { this.inboundHeaderNames = (inboundHeaderNames != null) ? inboundHeaderNames : new String[0]; this.inboundHeaderNamesLower = new String[this.inboundHeaderNames.length]; - for (int i = 0; i < inboundHeaderNames.length; i++) { + for (int i = 0; i < this.inboundHeaderNames.length; i++) { if (HTTP_REQUEST_HEADER_NAME_PATTERN.equals(this.inboundHeaderNames[i]) || HTTP_RESPONSE_HEADER_NAME_PATTERN.equals(this.inboundHeaderNames[i])) { this.inboundHeaderNamesLower[i] = this.inboundHeaderNames[i]; @@ -387,11 +388,11 @@ public class DefaultHttpHeaderMapper implements HeaderMapper, BeanF logger.debug(MessageFormat.format("outboundHeaderNames={0}", CollectionUtils.arrayToList(outboundHeaderNames))); } - Set headerNames = headers.keySet(); - for (String name : headerNames) { + for (Entry entry : headers.entrySet()) { + String name = entry.getKey(); String lowerName = name.toLowerCase(); if (this.shouldMapOutboundHeader(lowerName)) { - Object value = headers.get(name); + Object value = entry.getValue(); if (value != null) { if (!HTTP_REQUEST_HEADER_NAMES_LOWER.contains(lowerName) && !HTTP_RESPONSE_HEADER_NAMES_LOWER.contains(lowerName) && diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java index 02dd550023..1f7ec19600 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -77,7 +77,7 @@ public class TestingUtilities { int n = 0; while (serverConnectionFactory.isListening()) { try { - Thread.sleep(100); + Thread.sleep(delay); } catch (InterruptedException e) { Thread.currentThread().interrupt(); diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java index 6eaa243d11..ba85dfa03b 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -21,7 +21,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; +import java.util.Map.Entry; import javax.jms.Destination; import javax.jms.JMSException; @@ -139,11 +139,11 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper { logger.info("failed to set JMSType, skipping", e); } } - Set headerNames = headers.keySet(); - for (String headerName : headerNames) { + for (Entry entry : headers.entrySet()) { + String headerName = entry.getKey(); if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX) && jmsMessage.getObjectProperty(headerName) == null) { - Object value = headers.get(headerName); + Object value = entry.getValue(); if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) { try { String propertyName = this.fromHeaderName(headerName); diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/config/JmsChannelParser.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/config/JmsChannelParser.java index 33b89d99c2..d02b8b7e66 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/config/JmsChannelParser.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/config/JmsChannelParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -126,7 +126,7 @@ public class JmsChannelParser extends AbstractChannelParser { String prefetch = element.getAttribute("prefetch"); if (StringUtils.hasText(prefetch)) { if (containerType.startsWith("default")) { - builder.addPropertyValue("maxMessagesPerTask", new Integer(prefetch)); + builder.addPropertyValue("maxMessagesPerTask", Integer.valueOf(prefetch)); } } return builder; diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java index 2170eb998a..0a0e6ffd2c 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java @@ -76,7 +76,7 @@ public class ExponentialMovingAverage { sum = decay * sum + value; sumSquares = decay * sumSquares + value * value; weight = decay * weight + 1; - count++; + count++;//NOSONAR - false positive, we're synchronized } /** diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java index 8cd9859ef7..63024a8fda 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -22,16 +22,11 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.UUID; -import com.mongodb.BasicDBList; -import com.mongodb.BasicDBObject; -import com.mongodb.DB; -import com.mongodb.DBObject; -import com.mongodb.MongoException; - import org.springframework.beans.BeansException; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.BeanClassLoaderAware; @@ -81,6 +76,12 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; +import com.mongodb.BasicDBList; +import com.mongodb.BasicDBObject; +import com.mongodb.DB; +import com.mongodb.DBObject; +import com.mongodb.MongoException; + /** * An implementation of both the {@link MessageStore} and {@link MessageGroupStore} @@ -485,7 +486,7 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore } @Override - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"unchecked"}) public S read(Class clazz, DBObject source) { if (!MessageWrapper.class.equals(clazz)) { return super.read(clazz, source); @@ -534,8 +535,9 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore private Map normalizeHeaders(Map headers) { Map normalizedHeaders = new HashMap(); - for (String headerName : headers.keySet()) { - Object headerValue = headers.get(headerName); + for (Entry entry : headers.entrySet()) { + String headerName = entry.getKey(); + Object headerValue = entry.getValue(); if (headerValue instanceof DBObject) { DBObject source = (DBObject) headerValue; try { diff --git a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java index 23ce4c4512..9ed0bc3aad 100644 --- a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java +++ b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java @@ -100,7 +100,7 @@ public abstract class AbstractMqttMessageHandler extends AbstractMessageHandler } protected void incrementClientInstance() { - this.clientInstance++; + this.clientInstance++;//NOSONAR - false positive - called from synchronized block } @Override diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java b/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java index 3286c87910..abdf763c37 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -107,7 +107,8 @@ public abstract class TestUtils { ConfigurableListableBeanFactory configurableListableBeanFactory = null; if (beanFactory instanceof ConfigurableListableBeanFactory) { configurableListableBeanFactory = (ConfigurableListableBeanFactory) beanFactory; - } else if (beanFactory instanceof GenericApplicationContext) { + } + else if (beanFactory instanceof GenericApplicationContext) { configurableListableBeanFactory = ((GenericApplicationContext) beanFactory).getBeanFactory(); } if (bean instanceof BeanNameAware) { @@ -124,7 +125,7 @@ public abstract class TestUtils { throw new FatalBeanException("failed to register bean with test context", e); } } - configurableListableBeanFactory.registerSingleton(beanName, bean); + configurableListableBeanFactory.registerSingleton(beanName, bean);//NOSONAR false positive } diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java index dc6386214e..f4d85bf06a 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -18,6 +18,7 @@ package org.springframework.integration.xml.transformer; import java.io.IOException; import java.util.Map; +import java.util.Map.Entry; import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -41,7 +42,6 @@ import org.springframework.integration.xml.result.ResultFactory; import org.springframework.integration.xml.source.DomSourceFactory; import org.springframework.integration.xml.source.SourceFactory; import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.MessagingException; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; @@ -152,6 +152,7 @@ public class XsltPayloadTransformer extends AbstractXmlTransformer implements Be * * @param resultFactory The result factory. */ + @Override public void setResultFactory(ResultFactory resultFactory) { super.setResultFactory(resultFactory); this.resultFactoryExplicitlySet = true; @@ -327,8 +328,9 @@ public class XsltPayloadTransformer extends AbstractXmlTransformer implements Be // process individual mappings Transformer transformer = this.templates.newTransformer(); if (this.xslParameterMappings != null) { - for (String parameterName : this.xslParameterMappings.keySet()) { - Expression expression = this.xslParameterMappings.get(parameterName); + for (Entry entry : this.xslParameterMappings.entrySet()) { + String parameterName = entry.getKey(); + Expression expression = entry.getValue(); try { Object value = expression.getValue(this.evaluationContext, message); transformer.setParameter(parameterName, value); @@ -344,11 +346,11 @@ public class XsltPayloadTransformer extends AbstractXmlTransformer implements Be } } // process xslt-parameter-headers - MessageHeaders headers = message.getHeaders(); if (!ObjectUtils.isEmpty(this.xsltParamHeaders)) { - for (String headerName : headers.keySet()) { + for (Entry entry : message.getHeaders().entrySet()) { + String headerName = entry.getKey(); if (PatternMatchUtils.simpleMatch(this.xsltParamHeaders, headerName)) { - transformer.setParameter(headerName, headers.get(headerName)); + transformer.setParameter(headerName, entry.getValue()); } } }