diff --git a/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java b/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java index 7d263f5c1d..22e50c89c7 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 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. @@ -46,6 +46,8 @@ import org.springframework.util.Assert; * or {@link org.springframework.integration.handler.advice.IdempotentReceiverInterceptor}. * * @author Artem Bilan + * @author Gary Russell + * * @since 4.1 */ public class MetadataStoreSelector implements MessageSelector { @@ -81,9 +83,10 @@ public class MetadataStoreSelector implements MessageSelector { @Override public boolean accept(Message message) { String key = this.keyStrategy.processMessage(message); + Long timestamp = message.getHeaders().getTimestamp(); String value = (this.valueStrategy != null) ? this.valueStrategy.processMessage(message) - : Long.toString(message.getHeaders().getTimestamp()); + : (timestamp == null ? "0" : Long.toString(timestamp)); return this.metadataStore.putIfAbsent(key, value) == null; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java index 7317a58789..4ec2a75a99 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java @@ -198,7 +198,8 @@ public class SimpleMessageStore extends AbstractMessageGroupStore Message message = getMessage(id); if (message != null) { MessageMetadata messageMetadata = new MessageMetadata(id); - messageMetadata.setTimestamp(message.getHeaders().getTimestamp()); + Long timestamp = message.getHeaders().getTimestamp(); + messageMetadata.setTimestamp(timestamp == null ? 0L : timestamp); return messageMetadata; } else { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/AbstractIntegrationMessageBuilder.java b/spring-integration-core/src/main/java/org/springframework/integration/support/AbstractIntegrationMessageBuilder.java index 548dc3c9f7..f4b0d40123 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/AbstractIntegrationMessageBuilder.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/AbstractIntegrationMessageBuilder.java @@ -163,6 +163,7 @@ public abstract class AbstractIntegrationMessageBuilder { return copyHeadersIfAbsent(headers); } + @Nullable protected abstract List> getSequenceDetails(); protected abstract Object getCorrelationId(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/MessageBuilder.java b/spring-integration-core/src/main/java/org/springframework/integration/support/MessageBuilder.java index 70f47440ce..2987e5c38b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/MessageBuilder.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/MessageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -201,11 +201,13 @@ public final class MessageBuilder extends AbstractIntegrationMessageBuilder> getSequenceDetails() { return (List>) this.headerAccessor.getHeader(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS); } @Override + @Nullable protected Object getCorrelationId() { return this.headerAccessor.getCorrelationId(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java b/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java index 944e4a1b8e..0083a57bc0 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java @@ -18,6 +18,7 @@ package org.springframework.integration.support; import java.io.Serializable; import java.util.Map; +import java.util.UUID; import org.springframework.integration.store.SimpleMessageStore; import org.springframework.lang.Nullable; @@ -112,7 +113,9 @@ public class MutableMessage implements Message, Serializable { } if (obj != null && obj instanceof MutableMessage) { MutableMessage other = (MutableMessage) obj; - return (this.headers.getId().equals(other.headers.getId()) && + UUID thisId = this.headers.getId(); + UUID otherId = other.headers.getId(); + return (ObjectUtils.nullSafeEquals(thisId, otherId) && this.headers.equals(other.headers) && this.payload.equals(other.payload)); } return false; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java index b073121f51..c76bf6aef4 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -134,7 +134,7 @@ public class WhiteListDeserializingConverter implements Converter message) { Object payload = message.getPayload(); - if (payload == null) { - if (this.logger.isWarnEnabled()) { - this.logger.warn(this.getClass().getSimpleName() + " received null object"); - } - return; - } try { if (payload instanceof String) { this.stream.write(((String) payload).getBytes()); diff --git a/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandler.java b/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandler.java index f6f5f5b8b9..9b221b2496 100644 --- a/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandler.java +++ b/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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,9 +24,6 @@ import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.springframework.integration.handler.AbstractMessageHandler; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; @@ -41,11 +38,10 @@ import org.springframework.util.Assert; * {@link #setShouldAppendNewLine(boolean) shouldAppendNewLine} flag to 'true'. It is 'false' by default. * * @author Mark Fisher + * @author Gary Russell */ public class CharacterStreamWritingMessageHandler extends AbstractMessageHandler { - private final Log logger = LogFactory.getLog(this.getClass()); - private final BufferedWriter writer; private volatile boolean shouldAppendNewLine = false; @@ -136,12 +132,6 @@ public class CharacterStreamWritingMessageHandler extends AbstractMessageHandler @Override protected void handleMessageInternal(Message message) { Object payload = message.getPayload(); - if (payload == null) { - if (this.logger.isWarnEnabled()) { - this.logger.warn("target received null payload"); - } - return; - } try { if (payload instanceof String) { this.writer.write((String) payload);