Sonar Fixes
Packages `o.s.i.g*` * Polishing - PR comments
This commit is contained in:
committed by
Artem Bilan
parent
687e6d5004
commit
2cde493fbf
@@ -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.
|
||||
@@ -188,6 +188,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
|
||||
return mapArgumentsToMessage(arguments, headers);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Message<?> mapArgumentsToMessage(Object[] arguments, Map<String, Object> headers) {
|
||||
try {
|
||||
return this.argsMapper.toMessage(new MethodArgsHolder(this.method, arguments), headers);
|
||||
@@ -220,6 +221,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
|
||||
return context;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object evaluatePayloadExpression(String expressionString, Object argumentValue) {
|
||||
Expression expression =
|
||||
this.parameterPayloadExpressions.computeIfAbsent(expressionString, PARSER::parseExpression);
|
||||
@@ -317,7 +319,8 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
|
||||
}
|
||||
else if (annotation.annotationType().equals(Header.class)) {
|
||||
String headerName = determineHeaderName(annotation, methodParameter);
|
||||
if ((Boolean) AnnotationUtils.getValue(annotation, "required") && argumentValue == null) {
|
||||
if ((Boolean) AnnotationUtils.getValue(annotation, "required") // NOSONAR never null
|
||||
&& argumentValue == null) {
|
||||
throw new IllegalArgumentException("Received null argument value for required header: '"
|
||||
+ headerName + "'");
|
||||
}
|
||||
|
||||
@@ -434,6 +434,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||
final Class<?> returnType = invocation.getMethod().getReturnType();
|
||||
if (this.asyncExecutor != null && !Object.class.equals(returnType)) {
|
||||
@@ -458,16 +459,17 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
if (Mono.class.isAssignableFrom(returnType)) {
|
||||
return Mono.fromSupplier(new Invoker(invocation));
|
||||
}
|
||||
return this.doInvoke(invocation, true);
|
||||
return doInvoke(invocation, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Object doInvoke(MethodInvocation invocation, boolean runningOnCallerThread) throws Throwable {
|
||||
Method method = invocation.getMethod();
|
||||
if (AopUtils.isToStringMethod(method)) {
|
||||
return "gateway proxy for service interface [" + this.serviceInterface + "]";
|
||||
}
|
||||
try {
|
||||
return this.invokeGatewayMethod(invocation, runningOnCallerThread);
|
||||
return invokeGatewayMethod(invocation, runningOnCallerThread);
|
||||
}
|
||||
catch (Throwable e) { //NOSONAR - ok to catch, rethrown below
|
||||
this.rethrowExceptionCauseIfPossible(e, invocation.getMethod());
|
||||
@@ -709,7 +711,10 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
gateway.setRequestTimeout(-1);
|
||||
}
|
||||
else if (requestTimeout instanceof ValueExpression) {
|
||||
gateway.setRequestTimeout(requestTimeout.getValue(Long.class));
|
||||
Long timeout = requestTimeout.getValue(Long.class);
|
||||
if (timeout != null) {
|
||||
gateway.setRequestTimeout(timeout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
messageMapper.setSendTimeoutExpression(requestTimeout);
|
||||
@@ -718,7 +723,10 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
gateway.setReplyTimeout(-1);
|
||||
}
|
||||
else if (replyTimeout instanceof ValueExpression) {
|
||||
gateway.setReplyTimeout(replyTimeout.getValue(Long.class));
|
||||
Long timeout = replyTimeout.getValue(Long.class);
|
||||
if (timeout != null) {
|
||||
gateway.setReplyTimeout(timeout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
messageMapper.setReplyTimeoutExpression(replyTimeout);
|
||||
@@ -751,6 +759,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private <T> T convert(Object source, Class<T> expectedReturnType) {
|
||||
if (Future.class.isAssignableFrom(expectedReturnType)) {
|
||||
return (T) source;
|
||||
|
||||
@@ -396,6 +396,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
* @return the channel or null.
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public MessageChannel getErrorChannel() {
|
||||
if (this.errorChannelName != null) {
|
||||
synchronized (this) {
|
||||
@@ -431,6 +432,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Object receive() {
|
||||
this.initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
@@ -439,6 +441,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
return this.messagingTemplate.receiveAndConvert(replyChannel, Object.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Message<?> receiveMessage() {
|
||||
initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
@@ -447,6 +450,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
return this.messagingTemplate.receive(replyChannel);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Object receive(long timeout) {
|
||||
this.initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
@@ -455,6 +459,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
return this.messagingTemplate.receiveAndConvert(replyChannel, timeout);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Message<?> receiveMessage(long timeout) {
|
||||
initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
@@ -463,10 +468,12 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
return this.messagingTemplate.receive(replyChannel, timeout);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Object sendAndReceive(Object object) {
|
||||
return this.doSendAndReceive(object, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Message<?> sendAndReceiveMessage(Object object) {
|
||||
return (Message<?>) this.doSendAndReceive(object, false);
|
||||
}
|
||||
@@ -716,7 +723,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
* @return the attributes.
|
||||
* @since 4.3.10
|
||||
*/
|
||||
protected AttributeAccessor getErrorMessageAttributes(Message<?> message) {
|
||||
protected AttributeAccessor getErrorMessageAttributes(@Nullable Message<?> message) {
|
||||
return ErrorMessageUtils.getAttributeAccessor(message, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -351,10 +351,10 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
|
||||
}
|
||||
|
||||
private MessageGatewayNode gatewayNode(String name, MessagingGatewaySupport gateway) {
|
||||
String errorChannel = gateway.getErrorChannel() != null ? gateway.getErrorChannel().toString() : null;
|
||||
String requestChannel = gateway.getRequestChannel() != null
|
||||
? gateway.getRequestChannel().toString() // NOSONAR not null
|
||||
: null;
|
||||
MessageChannel gwErrorChannel = gateway.getErrorChannel();
|
||||
String errorChannel = gwErrorChannel != null ? gwErrorChannel.toString() : null;
|
||||
MessageChannel gwRequestChannel = gateway.getRequestChannel();
|
||||
String requestChannel = gwRequestChannel != null ? gwRequestChannel.toString() : null;
|
||||
return new MessageGatewayNode(this.nodeId.incrementAndGet(), name, gateway,
|
||||
requestChannel, errorChannel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user