Sonar Fixes
Final critical smells.
This commit is contained in:
committed by
Artem Bilan
parent
761af2730c
commit
a01d09f0f1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -163,6 +163,7 @@ public abstract class AbstractIntegrationMessageBuilder<T> {
|
||||
return copyHeadersIfAbsent(headers);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract List<List<Object>> getSequenceDetails();
|
||||
|
||||
protected abstract Object getCorrelationId();
|
||||
|
||||
@@ -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<T> extends AbstractIntegrationMessageBuilder<T
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
protected List<List<Object>> getSequenceDetails() {
|
||||
return (List<List<Object>>) this.headerAccessor.getHeader(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object getCorrelationId() {
|
||||
return this.headerAccessor.getCorrelationId();
|
||||
}
|
||||
|
||||
@@ -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<T> implements Message<T>, 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;
|
||||
|
||||
@@ -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<byte[], Object
|
||||
return this.deserializer.deserialize(byteStream);
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
catch (Exception ex) {
|
||||
throw new SerializationFailedException("Failed to deserialize payload. " +
|
||||
"Is the byte array a result of corresponding serialization for " +
|
||||
this.deserializer.getClass().getSimpleName() + "?", ex);
|
||||
|
||||
@@ -208,7 +208,10 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
|
||||
if (value != null) {
|
||||
if (!this.active) {
|
||||
this.template.boundListOps(uuid).rightPush(value);
|
||||
this.boundListOperations.rightPush(stringSerializer.serialize(uuid));
|
||||
byte[] serialized = stringSerializer.serialize(uuid);
|
||||
if (serialized != null) {
|
||||
this.boundListOperations.rightPush(serialized);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.extractPayload) {
|
||||
|
||||
@@ -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.
|
||||
@@ -20,9 +20,6 @@ import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
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;
|
||||
@@ -32,11 +29,10 @@ import org.springframework.messaging.MessagingException;
|
||||
* A {@link MessageHandler} that writes a byte array to an {@link OutputStream}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private final BufferedOutputStream stream;
|
||||
|
||||
|
||||
@@ -61,12 +57,6 @@ public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
|
||||
@Override
|
||||
protected void handleMessageInternal(Message<?> 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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user